I am downloading all of a user's tweets, using the twitter API.
When I download the tweets, I encode them in utf-8, before placing them in a CSV file.
tweet.text.encode("utf-8")
I'm using python 3
The issue is that this creates really weird characters in my files. For example, the tweet which reads
"But I’ve been talkin' to God for so long that if you look at my life, I guess he talkin' back."
Gets turned into
"b""But I\xe2\x80\x99ve been talkin' to God for so long that if you look at my life, I guess he talkin' back. """
(I see this when I open the CSV file that I wrote this encoded text to).
So my question is, how can I stop these weird characters from being created.
Also, if someone can explain what the b'
which starts every line, means, that would be super helpful.
Here is the full code:
outtweets = [ [tweet.text.encode('utf-8')] for tweet in alltweets]
#write the csv
with open('%s_tweets.csv' % screen_name, 'wt') as f:
writer = csv.writer(f)
writer.writerow(["text"])
writer.writerows(outtweets)