This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# importing library | |
import csv | |
def writeCSV(filename, columns_header, data): | |
with open(filename, mode='w') as csvfile: # opening file in write mode | |
writerObj = csv.writer(csvfile) # creating csv.writer object | |
writerObj.writerow(columns_header) # add columns value in csv | |
writerObj.writerows(data) # adding rows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# importing libraries | |
import csv | |
from prettytable import PrettyTable | |
def readAndFormat(filename): | |
with open(filename) as csvfile: # opeaning csv file in read mode | |
file_contents = csv.reader(csvfile) # reading file content using csv reader function | |
table = PrettyTable() # creating prettytable object | |
file_data = list(file_contents) # creating file object into a list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# importing library | |
import csv | |
def readCSV(filename): | |
with open(filename, mode = 'r') as csvfile: # opeaning a file in read mode | |
file_contents = csv.reader(csvfile) # read data from csv file using csv.reader function | |
for data in file_contents: # print the data using a for loop | |
print(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
url = "https://quotes.toscrape.com/" | |
page = requests.get(url) | |
if page.status_code == 200: | |
soup = BeautifulSoup(page.content, "html.parser") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pytube import YouTube | |
def download_Video(yt): | |
# filter mp4 streams from object | |
my_streams = yt.streams.filter(file_extension='mp4',only_video=True) | |
for streams in my_streams: | |
# print itag, resolution and codec format of Mp4 streams | |
print(f"Video itag : {streams.itag} Resolution : {streams.resolution} VCodec : {streams.codecs[0]}") | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# importing the module | |
from pytube import YouTube | |
# Function Takes YouTube Object as Argument. | |
def video_Info(yt): | |
print("Title : ",yt.title) | |
print("Total Length : ",yt.length," Seconds") | |
print("Total Views : ",yt.views) | |
print("Is Age Restricted : ",yt.age_restricted) | |
print("Video Rating ",round(yt.rating)) |