I am very new to Python. I know that this has already been asked, and I apologise, but the difference in this new situation is that spaces between strings are not equal. I
Why not to read a file line by line? Split a line into a list then rejoin a list with ','.
import csv
import os
for x in range(0,n): #n = max number of files
with open('input{}.txt'.format(x)) as fin, open('output.csv', 'a') as fout:
csv_output=csv.writer(fout)
for line in fin:
csv_output.writerow(line.split())