I have a script to stream in tweets in to a csv file and it works as i intended. However I have only managed to split the data between the text object of a tweet and the rest of the object, passing the text object into the string and then writing that to the csv file. However I would like to be able to append the location, co-ordinate, retweet_count, created_at to the string as well as be able to pull the location data from the user object.
This part of my code splits the streamed data and places the text object in the string:
tweet = data.split(’,“text”:"’).split(’","source’)
saveMe = tweet+’::’+’\n’
This above codes snippet works and appends a tweet like so:
Owen Smith says Labour ‘needs to highlight Brexit risks’: Sacked Owen Smith says he \u201cstood\u2026 https://t.co/KDDSJd4bdj::
However when i try change the snippet to try append other objects:
tweet = data.split(’,“text”:"’).split(’",“source’)
location = data.split(’,“location”:”’).split(’","source’)
saveMe = tweet+’::’+location+’\n’
I get an error
list index out of range
How would i be able to change this code to best append multiple twitter objects to the same string?