When writing to my CSV my list item gets broken up into individual strings even though I am using the append function. I think the problem is in how I am using writerow, but I'm not quite sure.
This is my code.
twitter = Twython(CONSUMER_KEY,CONSUMER_SECRET,ACCESS_KEY,ACCESS_SECRET)
input_path = 'doc_list.csv'
output_path = 'doc_tweets.csv'
docs_array = []
with open(input_path, 'r') as doc_file:
docs = csv.reader(doc_file)
for row in docs:
docs_array.append(row)
with open(output_path, 'w') as tweets_file:
writer = csv.writer(tweets_file, quoting=csv.QUOTE_MINIMAL, lineterminator='\n')
for name in docs_array:
tweet_list = []
user_timeline = twitter.get_user_timeline(screen_name=name, count=100, include_retweets=False)
for tweet in user_timeline:
tweet_list.append(tweet['text'])
for li in tweet_list:
writer.writerow(li)
del tweet_list[:]
del docs_array[:]
An example of what is in the list before it's iterated for writerow is
, '@etritabaugh gorgeous',
After being passed through writer.writerow(li) it becomes
@,e,t,r,i,t,a,b,a,u,g,h, ,g,o,r,g,e,o,u,s