Wednesday, 7 August 2013

fileinput - indexing lines out of order

fileinput - indexing lines out of order

I have got a huge txt file. I cannot use readlines() to read it because
Memory error appeared, so I have started to use fileinput. It works well
until I need to write some of its lines into another file, then I got
"accessing lines out of order". here is that part of my script:
input_4=fileinput.input([plik0_a]) out=open('out_file','w') for i in
range(s,e): out.writelines('%s' % input[i])
Please help me to find a way to write lines, which number is == i. I
assume that it is not difficult but I am just a beginner:).

No comments:

Post a Comment