Skip to content

Commit

Permalink
MatplotLib Basic programs
Browse files Browse the repository at this point in the history
  • Loading branch information
linrakesh committed Jul 15, 2019
1 parent 030d887 commit 8b82ae3
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 19 deletions.
18 changes: 18 additions & 0 deletions fileHandling/Create_binary_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# program to create a binary file of records - Just like structure
# made by : rakesh kumar
# Compiled on : 8-July-2018

import pickle
list =[]
while True:
roll = input("Enter student Roll No:")
sname = input("Enter student Name :")
student = {"roll":roll,"name":sname}
list.append(student)
choice= input("Want to add more record(y/n) :")
if(choice=='n'):
break

file = open("student.dat","wb")
pickle.dump(list,file)
file.close()
1 change: 1 addition & 0 deletions fileHandling/delete All File with extension_EXE.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def main():
for root, SubFolders , files in os.walk(directory):
os.chdir(root)
files = glob.glob('*.exe')
print(files)
for filename in files:
os.unlink(filename)
count+=1
Expand Down
23 changes: 23 additions & 0 deletions fileHandling/downloadPDF.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# program to download pdf file from any website.
#made by : rakesh kumar

import urllib.request

def download(tutorialName):
url = 'https://www.tutorialspoint.com/' + tutorialName + '/' + tutorialName + '_tutorial.pdf'
#url ="https://cbsetoday.com/wp-content/uploads/2018/05/MYSQL-ASS-4-class-XI.pdf"
downloadLocation = ''

pdf = urllib.request.urlopen(url)
saveFile = open(downloadLocation + tutorialName + '.pdf', 'wb') # because pdf is a binary file
saveFile.write(pdf.read())
saveFile.close()
print('Downloaded!')

if __name__ == '__main__':
while True:
tutorialName = input('Name of the tutorial pdf to be downloaded: ')
download(tutorialName)
choice = input("Do you want to download more PDF(y/n) :")
if(choice =='n'):
break
9 changes: 9 additions & 0 deletions fileHandling/read_binary_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#program to read a binary file of records - Just like structure
# made by : rakesh kumar
# Compiled on : 8-July-2018

import pickle
file = open("student.dat","rb")
list = pickle.load(file)
print(list)
file.close()
9 changes: 9 additions & 0 deletions matplotlib/bar_Graph.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# program to print scatter graph on the screen
# made by : rakesh kumar

import matplotlib.pyplot as plt
import numpy as np
x = ['Delhi','Banglore','Chennai','Pune']
y = [250,300,260,400]
plt.bar(x,y)
plt.show()
9 changes: 9 additions & 0 deletions matplotlib/line_graph.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# program to print scatter graph on the screen
# made by : rakesh kumar

import matplotlib.pyplot as plt
import numpy as np
x = ['Delhi','Banglore','Chennai','Pune']
y = [250,300,260,400]
plt.plot(x,y)
plt.show()
9 changes: 9 additions & 0 deletions matplotlib/pie_graph.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# program to print scatter graph on the screen
# made by : rakesh kumar

import matplotlib.pyplot as plt
import numpy as np
x = ['Delhi','Banglore','Chennai','Pune']
y = [250,300,260,400]
plt.pie(y,labels= x)
plt.show()
6 changes: 6 additions & 0 deletions matplotlib/scatter_graph.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import matplotlib.pyplot as plt
import numpy as np
x = ['Delhi','Banglore','Chennai','Pune']
y = [250,300,260,400]
plt.scatter(x,y)
plt.show()
Binary file added student.dat
Binary file not shown.
39 changes: 20 additions & 19 deletions webscraper/imagedownloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,25 @@ def downloader(image_url,path):
address = "https://www.pexels.com/search/{}".format(query)
#webbrowser.open(address)

root = tk.Tk()
root.withdraw()
directory = filedialog.askdirectory()
if __name__ == '__main__':
root = tk.Tk()
root.withdraw()
directory = filedialog.askdirectory()

r = requests.get(address)
data = r.text
soup = BeautifulSoup(data,"html.parser")
for link in soup.select('.js-photo-link img'):
name = link.get('srcset')
len = (name.find('?'))
newname = name[0:len]
print(newname)
#webbrowser.open(newname)
downloader(newname,directory)
print("Download complete check your folder")
#root = tk.Tk()
#root.withdraw()
#directory = filedialog.askdirectory() #source folder
r = requests.get(address)
data = r.text
soup = BeautifulSoup(data,"html.parser")
for link in soup.select('.js-photo-link img'):
name = link.get('srcset')
len = (name.find('?'))
newname = name[0:len]
print(newname)
#webbrowser.open(newname)
downloader(newname,directory)
print("Download complete check your folder")
#root = tk.Tk()
#root.withdraw()
#directory = filedialog.askdirectory() #source folder

#url ="http://www.binarynote.com/wp-content/themes/binarynote3/images/main.jpg"
#downloader(link.get(srcset,directory))
#url ="http://www.binarynote.com/wp-content/themes/binarynote3/images/main.jpg"
#downloader(link.get(srcset,directory))
12 changes: 12 additions & 0 deletions webscraper/wikipedia.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# python program to download wikipedia page
# made by : rakesh kumar


import requests
req = requests.post('https://binarynote.com', data = {'search':'wordpress'})
req.raise_for_status()
with open('wordpress.html', 'wb') as fd:
for chunk in req.iter_content(chunk_size=50000):
fd.write(chunk)

print("File generated...")

0 comments on commit 8b82ae3

Please sign in to comment.