Dear All,
I am opening a file called initialisation:
try:
initFile = open("initialisation.dat", "r")
except IOError:
print ("Initialisation file cannot be openned for reading")
I would like to read the contents of this file and then print them on several other files i.e. file1, file2, file3, file4, etc.
i am writing the following code which generates maxValues = 20 files but it only writes the content of the initFile in file1 and not the rest.
maxValue = 20
for i in range(1, maxValue+1, 1):
onitFile = open("File%d.txt" % i, "w")
fileHandle = initFile.readlines()
for fileLine in fileHandle:
onitFile.write(fileLine)
onitFile.close()
initFile.close()
Could you please comment on how to fix this problem?
Thanks very much in advance.
Nicholas