Reading from input file.

Sheldon shejo284 at gmail.com
Thu Jan 12 03:39:27 EST 2006


Hi,

after you have read the file then split it like this:
file = open('inputfile.txt', 'r').read()
import string
file = string.split(file,'\n')
now if you print file[0] you should only get the first line.
Be careful and examine the file for non-continuous sections where a
line is empty. That is to say where file[x] = ' '. You should remove
these lines from the txt files before you read it with python. It maybe
so that python reads the entire file, empty spaces and all, and then
you have to remove them after the split with a WHERE statement. This is
a much easier way so lets hope that this is so.

I hope this was more clear and helpful this time around.

Cheers
Sheldon




More information about the Python-list mailing list