I am a newbie! yay! i would love it if someone can show me how to copy part of a text file to a new text file. *for instance assuming that the part of the file i want to copy goes from 'tommy' to 'jenny'
dunno if this makes sense, but it prints all the lines from the flat file 'CLIENTS.CSV' where the first letter is L
I am sure there are easy ways - but it's all I could think of on the spur of the moment.
I tried it on a 24mb client file and it only took a second to work out (took ages to display it to screen)
Peter
file = file('d:\\CLIENTS.CSV').readlines()
startline, endline, counter = 0, 0, 0
for line in file:
counter = counter +1
if line.startswith('L') and startline==0:
startline = counter
endline = counter
if line.startswith('M') and startline==endline:
endline = counter
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.