I use this code to get the tweet from the feed which i write inside a file. When i read the file and try to json the lines i always get an ERROR.
def SearchTwt(api):
os.chdir('/Users/me/Desktop')
SearchResult = api.search( q='market',lang='en',rpp=20)
text_file = open("TweetOut.txt", "w")
for tw in SearchResult:
text_file.write(str(tw))
print(str(tw))
text_file.close()
I read the file with:
def readfile():
tweets_data = []
os.chdir('/Users/me/Desktop')
file = open("TweetOut.txt", "r")
for line in file:
parts = line.split("Status(")
print (len(parts))
for part in parts:
tweet = 'Status('+part
if len(tweet) > 10:
tweetj = json.loads(tweet)
#tweets_data.append(tweet)
print(tweet)
file.close()
May be this is wrong to fill the file with str(tw)? Yes I rebuild the string during the reading because i thought the tweet started like that. So may be another mistake.
I tried a lot of other options.
the error: raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
the file starts like this (edited the url as asked by stack): Status(source='SocialFlow', id=757991135465857024, in_reply_to_status_id=None, is_quote_status=False, entities={'hashtags': [], 'user_mentions': [], 'symbols': [], 'urls': [{'url': '', 'expanded_url': '', 'display_url':