python - not being able to write the last row into csv -
my parent dataset contains 1 tweet in each row. cleaning tweets , extracting feature words tweets , exporting csv. being able export 1 last row. using follwoing piece of code:
#read tweets 1 one , process fp = open('c:/twitter_crawl/tweetdb4_import.csv', 'r') st = open('c:/twitter_crawl/stopwords.txt', 'r') stopwords = getstopwordlist('c:/twitter_crawl/stopwords.txt') line in fp.readlines(): = csv.writer(open('feature_vector.csv', 'a')) processedtweet = processtweet(line) featurevector = getfeaturevector(processedtweet) a.writerow(featurevector) print (featurevector) #end loop fp.close()
can please me out looping last row gets exported?
thanks in advance!
you need close file feature_vector.csv. opening every time through loop, bad. open once before loop , close once afterward.
also variable st not used.
Comments
Post a Comment