write multiple files python code example
Example 1: write in multiple files python
fn = open("path of input file.txt","r")
fnew = fn.read()
fs = fnew.split('\n')
for value in fs:
f = [open("path of output file to write.txt" %i,'w') for i in range(len(list_of_files))]
f.write(value)
f.close()
Example 2: write in multiple files python
fn = open("path of input file.txt","r")
for i, line in enumerate(fn):
f = open("/home/vidula/Desktop/project/ori_tri/input_%i.data" %i,'w')
f.write(line)
f.close()