new user needs help!
Steve Holden
steve at holdenweb.com
Tue Apr 8 17:33:45 EDT 2008
Tim Chase wrote:
>> f = open("/tmp/data.txt", 'w')
>>
>> will open that file.
>>
>> You can throw the first line away with
>>
>> headings = f.next()
>>
>> Then you can loop over the rest with
>>
>> for name, aa, topo, access, dssp, stride, z in file:
>> #
>> # Then process each line here
>
>
> Small caveat here...Steve changed file-variables on you here, and
> assumed a tuple-unpacking that won't work. You'll want something like
>
> for line in f:
> (name, aa, topo, access, dssp, stride, z) = (
> line.rstrip('\n').split('\t')
> # process the line here
>
> I don't know how your fields are delimited, whether by spaces or tabs.
> In the above code, I split by tabs, but you can just use .split() if it
> should be split on any white-space. It's a bit more complex if you need
> to split by column-offsets.
>
Hmm, perhaps I shoudl wait until I get my brain fixed before I post
again! Sorry, Tim, I got distracted and shouldn't have tried to dash off
the post before coping with the distraction. Just a minor flood in the
basement ...
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
More information about the Python-list
mailing list