mercredi 29 juillet 2015

Iterating through a List of Lists and calling variables explicitly

Below is a small snip of the list of lists that I am currently working with.

[(datetime.datetime(2015, 7, 27, 17, 33, 1), 'derivative', 74L, 980750911L, 150.
49), (datetime.datetime(2015, 7, 27, 17, 33, 1), 'other', 211L, 2519735424L, 383
.99), (datetime.datetime(2015, 7, 27, 17, 33, 1), 'source', 9L, 68556768874L, 31
27.9)]

Now, my end game goal is iterating through this list of lists to separate values so I can write them to an excel file. My issue is the separation of the values. For example I know how to print out all the values of each value in the list of lists with this

for x in data:
    for x in x:
        print x 

The return format is as so after that is executed.

2014-06-28 21:50:54
source
27
14144158722
1425.26

Now, how can I call on one specific value in that return, for example if I wanted to make an if statement that only printed out x in the list of lists if the x had source in its content. I tried to explain this thoroughly, ready to provide any clarification.

Aucun commentaire:

Enregistrer un commentaire