I have a csv file that I've turned into a list()
so that I can iterate over it to do some simple transformations with the data, however when I try to get the output I only get the key for each of the items (when what I need are the values).
The code I'm using right now is as follows (slightly truncated for clarity):
lines = list(csvdataFishes)
while (startTime + 30) > timeToEpoch(currLine['timestamp']) >= startTime:
cx = someFunction1()
uf = someFunction2()
rf = someFunction3()
pc = someFunction4()
outline = [k for k in lines[i] if k is not ''] + [cx,uf,rf,pc]
print ','.join(outline)
i += 1
currLine = lines[i]
startTime = startTime + 30
If I do a simple print lines[i]
I get something like:
{
'adjusted timestamp': '2014-08-23 17:20:05.43000',
'fishType': 'small green fish',
'playerID': '3',
'timestamp': '2014-08-23 16:21:05.430000-05:00',
'targetID': '34',
'lights': '1',
'event': 'MakeSpawnFish'
}
but the output of print ','.join(outline)
just gives me the keys for the [k for k in lines[i] if k is not '']
and the correct output for [cx,uf,rf,pc]
(like so):
adjusted timestamp,fishType,playerID,timestamp,targetID,lights,event,1,1,2,1
What I'm wondering is how I get it to give the values (and not the key) for the [k for k in lines[i] if k is not '']