i got error while writing data to file
cannedham284 at hotmail.com
Mon Mar 13 12:42:27 EDT 2017
I don't know much about web scraping but I can explain why your output is so much smaller than your input: you keep writing over your output file. The way I see it you have two options:
1. Where you wrote "mode='wt'", change "wt" to "at". The replacement "at" appends your output text, as opposed to "wt", which writes over your output text as if the file hadn't already existed.
2. Leave the file modes alone, but move the "with" statement further up the "for" block. If you use this option, your code should look more like below (if email didn't garble the formatting):
with open('E:/amadown2py-master/reviews1.csv', 'r',encoding='UTF8') as csvfile:
mycsv = csv.reader(csvfile)
for row in mycsv:
data = row
with open('E:/amadown2py-master/Sam7_pos_rev.txt',mode='wt') as myfile:#Moved this!
score = ast.literal_eval(row)
if score > 3:
#myfile.close()#You shouldn't need this, bc you're using "with"
Of the two options, I would think that option 1 is easier.
More information about the Python-list