Numpy array2string write to file - unwanted string split

I loop through my numpy matrix row by row, I convert each row to a string and write to a file, it looks like each string is split into two in the output instead of all being on the same text line:
A shortened version of my code is:

for row in my_matrix:
    my_str = np.array2string(row, separator=',') 
    myfile.write("\t\t" + my_str[1:-1] + ",\\\n")

To simplify - what I actually get in the file is

    0,1,2,3,4,5,6,7,8,9,
10,11,12,14,15,\

but what I actually want is
0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,\

It’s got to be something simple ?

I needed to add , max_line_width=270 to array2string eg:
my_str = np.array2string(row, separator=β€˜,’, max_line_width=270)

2 Likes