Help please: Reading .txt file with multiple array of numbers the right way

Try this. It only uses standard library and built in functions.

import csv                                     # python has a csv module, see docs.
outfile = 'x.csv'
infile = 'x.data'
with open(outfile, 'w', newline = '') as fout: # need to add "newline = ''"" as csv does it own thing see docs
    write = csv.writer(fout)                   # get a csv writer to output formatteded dats
    with open(infile) as fin:                  # files closed at end with block
        for line in fin:                       # looping over a text file gets you a new line each time.
            line = line.strip()                # get rid of excess space and end of line
            lst = eval(line)                   # this works as the data in the input file looks like a list on each line
            write.writerow(lst)                # splits the list and adds the commas

Its not the shortest way to do it but I think its clear