input file format

Steven D'Aprano steve+comp.lang.python at
Tue Aug 9 23:48:04 EDT 2011

On Wed, 10 Aug 2011 01:00 pm Etay wrote:

> Is there some simple way to skip over the lines I don't need, and then
> inform Python about the format of the lines with the data I do need
> within a loop?

Yes. It's called "programming" :)

f = open('some file')
for line in f:
    if some_condition(line):
        continue  # skip the line

some_condition can be anything you like. You just have to write the code to
make it so.


More information about the Python-list mailing list