Python; jump to a concrete line

Rob Wolfe rw at smsnet.pl
Thu Dec 20 14:47:36 EST 2007


Horacius ReX <horacius.rex at gmail.com> writes:

> Hi, sorry but after looking for information, I still did not get how,
> when reading a text file in python, can one jump to a concrete line
> and then read the different data (separated by spaces). In each line
> there is different number of columns so sometimes i get kind of "index
> out" error. Is there a better way to read the different data on each
> row and avoiding to know the exact number of columns ?

Consider using linecache:
http://docs.python.org/lib/module-linecache.html

HTH,
Rob



More information about the Python-list mailing list