I have Python getting a long text file and breaking off 50 line chunks of it.
I would like to save those to text files with a progressive number in the name (like 001.txt, 002.txt, 003.txt ect…), but I am a little un-clear on this part.
I need to format an integer and make a string wiith leading zeros of of a fixed size (in my case 7, 0’s) .
# Copy first 50 lines to output file
if( evt == 5 ):
counterStr = right$( "000000" + resr( counter ), 7 )
outputFile = outputPrefix + resr( counter ) + ".txt"
f=open( outputFile,'w')
f2 = open( inputFile, 'r')
for i in range(1,50):
templine = f2.readline()
f.write( templine )
f.close()
f2.close()
How do I to manipulate strings, like BASIC does for example with Left$(), Right$(), Mid$(),& Len() functions…