import csv
import os

# we want the tittle, the price, the sucribers
# review, percentage of review, lenght 

#udemy_csv = "./resources/web_starter.csv"
udemy_csv = os.path.join(".","resources","web_starter.csv")


title = []
price = []
subscribers = []
reviews = []
review_percentage=[]
lenght = []

with open(udemy_csv, "r") as csvfile:
    csvreader = csv.reader(csvfile,delimiter=",")
    #test = next(csvreader)
    for row in csvreader:
        #add title
        title.append(row[1])
        #add price
        price.append(row[4])
        #add subscribers
        subscribers.append(row[5])
        #add reviews
        reviews.append(row[6])
        #add percentage    
        percent = round(int(row[6])/int(row[5])*100,2)
        review_percentage.append(percent)
        #lenght
        new_lenght = row[9].split(" ")
        lenght.append(float(new_lenght[0]))



merge = zip(title,price,subscribers,reviews,review_percentage,lenght)
file = os.path.join("webFinal.csv")

with open(file,"w") as datafile:
    writer=csv.writer(datafile)
    #add header
    writer.writerow(["Tittle","Price","Subscriber","Reviews","Percentage of Reviews","lenght"])
    #add all the lines for the file that was selected in wth.. open, attention the 's' in rows
    writer.writerows(merge)



#print (review_percentage)
#print (test)



2f190d8f22f14a19b96dcaeea8238148d5dbc75a
<mask token>

<mask token>
with open(udemy_csv, 'r') as csvfile:
    csvreader = csv.reader(csvfile, delimiter=',')
    for row in csvreader:
        title.append(row[1])
        price.append(row[4])
        subscribers.append(row[5])
        reviews.append(row[6])
        percent = round(int(row[6]) / int(row[5]) * 100, 2)
        review_percentage.append(percent)
        new_lenght = row[9].split(' ')
        lenght.append(float(new_lenght[0]))
<mask token>
with open(file, 'w') as datafile:
    writer = csv.writer(datafile)
    writer.writerow(['Tittle', 'Price', 'Subscriber', 'Reviews',
        'Percentage of Reviews', 'lenght'])
    writer.writerows(merge)

<mask token>
udemy_csv = os.path.join('.', 'resources', 'web_starter.csv')
title = []
price = []
subscribers = []
reviews = []
review_percentage = []
lenght = []
with open(udemy_csv, 'r') as csvfile:
    csvreader = csv.reader(csvfile, delimiter=',')
    for row in csvreader:
        title.append(row[1])
        price.append(row[4])
        subscribers.append(row[5])
        reviews.append(row[6])
        percent = round(int(row[6]) / int(row[5]) * 100, 2)
        review_percentage.append(percent)
        new_lenght = row[9].split(' ')
        lenght.append(float(new_lenght[0]))
merge = zip(title, price, subscribers, reviews, review_percentage, lenght)
file = os.path.join('webFinal.csv')
with open(file, 'w') as datafile:
    writer = csv.writer(datafile)
    writer.writerow(['Tittle', 'Price', 'Subscriber', 'Reviews',
        'Percentage of Reviews', 'lenght'])
    writer.writerows(merge)

import csv
import os
udemy_csv = os.path.join('.', 'resources', 'web_starter.csv')
title = []
price = []
subscribers = []
reviews = []
review_percentage = []
lenght = []
with open(udemy_csv, 'r') as csvfile:
    csvreader = csv.reader(csvfile, delimiter=',')
    for row in csvreader:
        title.append(row[1])
        price.append(row[4])
        subscribers.append(row[5])
        reviews.append(row[6])
        percent = round(int(row[6]) / int(row[5]) * 100, 2)
        review_percentage.append(percent)
        new_lenght = row[9].split(' ')
        lenght.append(float(new_lenght[0]))
merge = zip(title, price, subscribers, reviews, review_percentage, lenght)
file = os.path.join('webFinal.csv')
with open(file, 'w') as datafile:
    writer = csv.writer(datafile)
    writer.writerow(['Tittle', 'Price', 'Subscriber', 'Reviews',
        'Percentage of Reviews', 'lenght'])
    writer.writerows(merge)

import csv
import os

# we want the tittle, the price, the sucribers
# review, percentage of review, lenght 

#udemy_csv = "./resources/web_starter.csv"
udemy_csv = os.path.join(".","resources","web_starter.csv")


title = []
price = []
subscribers = []
reviews = []
review_percentage=[]
lenght = []

with open(udemy_csv, "r") as csvfile:
    csvreader = csv.reader(csvfile,delimiter=",")
    #test = next(csvreader)
    for row in csvreader:
        #add title
        title.append(row[1])
        #add price
        price.append(row[4])
        #add subscribers
        subscribers.append(row[5])
        #add reviews
        reviews.append(row[6])
        #add percentage    
        percent = round(int(row[6])/int(row[5])*100,2)
        review_percentage.append(percent)
        #lenght
        new_lenght = row[9].split(" ")
        lenght.append(float(new_lenght[0]))



merge = zip(title,price,subscribers,reviews,review_percentage,lenght)
file = os.path.join("webFinal.csv")

with open(file,"w") as datafile:
    writer=csv.writer(datafile)
    #add header
    writer.writerow(["Tittle","Price","Subscriber","Reviews","Percentage of Reviews","lenght"])
    #add all the lines for the file that was selected in wth.. open, attention the 's' in rows
    writer.writerows(merge)



#print (review_percentage)
#print (test)


