appending into a list
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Tue Oct 30 15:38:51 EDT 2007
c james a écrit :
> Beema shafreen wrote:
>
>> 2721520 2721569 A_16_P21360235 199 -49
>> 2721768 2721821 A_16_P03641971 139 -53
>> 2721960 2722004 A_16_P21360237 312 -44
>>I need to append the column D and E into a list:
>> in such a way that the list should have
>>[D,E,D,E,D,E........]
>>How do i do it.
>>
>>regards
>>shafreen
>
>
> Without a header, you could use something like
>
> data = [x.split()[-2:] for x in open(filename).readlines()]
>
> With header
>
> f = open(filename)
> f.readline()
> data = [x.split()[-2:] for x in f.readlines()]
>
>
Or just use the CSV module ?
More information about the Python-list
mailing list