Line indexing in Python
seafoid
fitzpadj at tcd.ie
Fri Dec 18 13:22:56 EST 2009
Hi Guys,
It has been point out that it is difficult for anyone to provide suggestions
if I do not outline more clearly my input file and an example of what I wish
to do with it (Thanks Rory!).
I mentioned it in this thread (Is creating different threads bad etiquette?
If so, lesson learned!):
http://old.nabble.com/Parsing-file-format-to-ensure-file-meets-criteria-to26837682.html
Hope you guys may have some suggestions as I am stumped!
Thanks,
Seafoid :-)
seafoid wrote:
>
> Hi Guys,
>
> When python reads in a file, can lines be referred to via an index?
>
> Example:
>
> for line in file:
> if line[0] == '0':
> a.write(line)
>
> This works, however, I am unsure if line[0] refers only to the first line
> or the first character in all lines.
>
> Is there an easy way to refer to a line with the first character being a
> single letter that you know?
>
> Thanks in advance,
> Seafoid.
>
--
View this message in context: http://old.nabble.com/Line-indexing-in-Python-tp26845253p26847598.html
Sent from the Python - python-list mailing list archive at Nabble.com.
More information about the Python-list
mailing list