new user needs help!
Tim Chase
python.list at tim.thechases.com
Tue Apr 8 16:49:59 EDT 2008
> 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.
-tkc
More information about the Python-list
mailing list