I have about 1,000,000 records that I would like to loop through and write the contents in about 10 different files.
Below is my code that successfully create a single large file :
f = open("c:\temp\filename", 'w+')
# write to file
for rec in full_data:
f.write(rec[0])
f.write("\n")
I want to create 10 files with 100,000 records in each file.
I tried creating multiple files but this will create file for each row:
for index, line in enumerate(full_data):
with open('filename{}.txt'.format(index), 'w') as output:
output.write(line[0])
Please let me know how can create each file for 100,00 records.