i got error while writing data to file
Madhusudhanan Sambath
ssmadhu80 at gmail.com
Mon Mar 13 07:25:50 EDT 2017
hi to all,
this is madhu...i am new to python
this is my python code, where i labeled the reviews taken from amazon as positive, negative and neutral based on review score
i have collected reviews and scores from amazon scrap prg, but i have problem while doing labelling.kindly help me
import nltk
import csv
import ast
data=[]
positivedata=[]
negativedata=[]
neutraldata=[]
with open('E:/amadown2py-master/reviews1.csv', 'r',encoding='UTF8') as csvfile:
mycsv = csv.reader(csvfile)
for row in mycsv:
data = row[0]
#print (data)
try:
score = ast.literal_eval(row[1])
if score > 3:
cnt=0;
#print (score)
print (data)
positivedata.append((data))
with open('E:/amadown2py-master/Sam7_pos_rev.txt',mode='wt') as myfile:
myfile.writelines('\n'.join(positivedata))
myfile.close()
the above program is able to create file but full reviews are not read from csv . if i print the details about 48kb size, i got more data , but in file it have only 3kb why?kinldy help me
More information about the Python-list
mailing list