Searched for this but the answers dont seem to apply to my case. For some reason, the list returned is acknowledging that there are multiple lines, but return the same dictionary over and over again...here's my code:
import io with io.open(filename, "r", encoding="utf-8") as my_file: #empty list for storing dictionaries
tweet_list=[]
tweet={}
#for loop to read and format txt line
x= 0
for readtweet in my_file:
#print(readtweet)
import datetime as dtime
#**REMEMBER TO COME BACK & ADD CODE THAT SKIPS STUFF WOUT
#read line
#tweet1 = my_file.readline()
#make it a list
tw= readtweet.split('\t')
#print(tw)
#format coordinates
coord_list= tw[0].split(',')
lat_format= coord_list[0].strip('[')
long_format= coord_list[1].strip(']')
latitude= float(lat_format)
longitude= float(long_format)
#store tweet context as 'text'
text= str(tw[3])
#print(text)
#format time
dt=tw[2].split()
dt[0]=dt[0].split('-')
dt[1]=dt[1].split(':')
year= int(dt[0][0])
month= int(dt[0][1])
day= int(dt[0][2])
hour= int(dt[1][0])
minute= int(dt[1][1])
seconds= int(dt[1][2])
time= dtime.datetime(year,month,day,hour,minute,seconds)
#for loop for assigning value
tweet['text']= text
tweet['time']= time
tweet['latitude']= latitude
tweet['longitude']= longitude
#print(tweet)
#for loop for adding dict to list
tweet_list.append(tweet)
return(tweet_list)