Skip to content

Commit

Permalink
python tools
Browse files Browse the repository at this point in the history
  • Loading branch information
linrakesh committed Jan 22, 2020
1 parent 805b4ad commit 0efcf03
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 9 deletions.
16 changes: 16 additions & 0 deletions Tools/SampleData.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Rank,Name,Platform,Year,Genre,Publisher,NA_Sales,EU_Sales,JP_Sales,Other_Sales,Global_Sales
1,Wii Sports,Wii,2006,Sports,Nintendo,41.49,29.02,3.77,8.46,82.74
2,Super Mario Bros.,NES,1985,Platform,Nintendo,29.08,3.58,6.81,0.77,40.24
3,Mario Kart Wii,Wii,2008,Racing,Nintendo,15.85,12.88,3.79,3.31,35.82
4,Wii Sports Resort,Wii,2009,Sports,Nintendo,15.75,11.01,3.28,2.96,33
5,Pokemon Red/Pokemon Blue,GB,1996,Role-Playing,Nintendo,11.27,8.89,10.22,1,31.37
6,Tetris,GB,1989,Puzzle,Nintendo,23.2,2.26,4.22,0.58,30.26
7,New Super Mario Bros.,DS,2006,Platform,Nintendo,11.38,9.23,6.5,2.9,30.01
8,Wii Play,Wii,2006,Misc,Nintendo,14.03,9.2,2.93,2.85,29.02
9,New Super Mario Bros. Wii,Wii,2009,Platform,Nintendo,14.59,7.06,4.7,2.26,28.62
10,Duck Hunt,NES,1984,Shooter,Nintendo,26.93,0.63,0.28,0.47,28.31
11,Nintendogs,DS,2005,Simulation,Nintendo,9.07,11,1.93,2.75,24.76
12,Mario Kart DS,DS,2005,Racing,Nintendo,9.81,7.57,4.13,1.92,23.42
13,Pokemon Gold/Pokemon Silver,GB,1999,Role-Playing,Nintendo,9,6.18,7.2,0.71,23.1
14,Wii Fit,Wii,2007,Sports,Nintendo,8.94,8.03,3.6,2.15,22.72
15,Wii Fit Plus,Wii,2009,Sports,Nintendo,9.09,8.59,2.53,1.79,22
21 changes: 21 additions & 0 deletions Tools/csv_to_html.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# python program to convert any csv file into html file
# made by : rakesh kumar

import csv
html = "<table>"
with open("E:/python/Tools/SampleData.csv") as csv_file:
csv_data = csv.reader(csv_file)
count = 1
for row in csv_data:
html += "<tr>"
if count == 1:
for y in row:
html += "<th>"+y+"</th>"
else:
for y in row:
html += "<td>"+y+"</td>"
html += "</tr>"
count += 1

html += "</table>"
print(html)
19 changes: 19 additions & 0 deletions Tools/csv_to_json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import csv
json = []
keys = []
with open("E:/python/Tools/SampleData.csv") as csv_file:
csv_data = csv.reader(csv_file)
count = 1
for row in csv_data:
if count == 1:
for y in row:
keys.append(y)
else:
element = {}
for y in range(len(row)):
element[keys[y]] = row[y]
json.append(element)

count = count+1

print(json)
21 changes: 21 additions & 0 deletions dictionary/frequency.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
L = ['the', 'in', 'out', 'the', 'in', 'ram', 'umesh', 'the']
d = {}

""" l = len(L)
for i in range(0, l):
key = L.count(L[i])
if key not in d:
value = []
for j in range(i, l):
if(L.count(L[j]) == key and L[j] not in value):
value.append(L[j])
d[key] = value
"""

for i in L:
c = L.count(i)
if c not in d:
d[c] = [i]
elif i not in d[c]:
d[c].append(i)
print(d)
41 changes: 41 additions & 0 deletions fileHandling/commentor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# program to add comment at the begining of each python file having extension .py
# made by : rakesh kumar
# licence : MIT

import os
import sys # module for terminating
import glob
import tkinter as tk
from tkinter import filedialog

str = "# program to comment on every file \n"
str = str + "# made by : rakesh kumar \n"
str = str+" # class - : xi A \n"
str = str+" # session :2019-20 \n\n"


def add_comment(filename):
with open(filename, "r") as f:
data = f.read()

with open("abc.txt", "w") as f:
f.write(str)
f.write(data)

os.unlink(filename)
os.rename("abc.txt", filename)


if __name__ == "__main__":
root = tk.Tk()
root.withdraw()
directory = filedialog.askdirectory() # source folder
count = 0
for root, SubFolders, files in os.walk(directory):
os.chdir(root)
files = glob.glob('*.py')
# print(files)
for filename in files:
print(filename, 'Comment Added')
add_comment(filename)
count += 1
13 changes: 11 additions & 2 deletions json/import_json.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
import json
import requests
source = requests.get('https://jsonplaceholder.typicode.com/todos/1')
print(source.read())
url = ('https://newsapi.org/v2/top-headlines?'
'country=in&'
'apiKey=2121032f088e4370affe13ca317f8d1a')
response = requests.get(url)

#source = requests.get('https://jsonplaceholder.typicode.com/todos/1')
data = json.loads(response.text)

for article in data['articles']:
print(article['author'], end="-")
print(article['title'])
9 changes: 2 additions & 7 deletions webscraper/youtubeDownloader.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
from __future__ import unicode_literals
import youtube_dl
# import urllib
# import shutil
# import shutil
ydl_opts = {}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(
<<<<<<< HEAD
['https://www.youtube.com/watch?v=skG_36Abhos'])
=======
['https://www.youtube.com/watch?v=7nH2NYpeKa4&list=PLuiqR73XWRBZ7PpaADMES1LCtvzkc2MJt&index=1'])
>>>>>>> 1ddf82b2ad35dc035189900c6208296c03e16f97
ydl.download(['https://www.youtube.com/watch?v=wF_B_aagLfI'])

0 comments on commit 0efcf03

Please sign in to comment.