python - Writing arrays to text file in particular fomat -
i'm new python , struggling below format.
i have 3 arrays of same size. a=[1,2,3]
, b=[4,5,6]
, c=[7,8,9]
. want write them text file second line. first line has text 3 columns, a, b , c. want output like
a b c 1 4 7 2 5 6 3 8 9
i tried using numpy.savetxt('test.txt', (a,b,c), '%s', delimiter='\t')
. not give format want. actual data contain 14 columns each column having 1200 values. can please me?
if parsing later important you, must suggest writing csv files.
import csv data = [['a', 'b', 'c'], ['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']] open('testing.csv', 'w', newline='') file: csv = csv.writer(file, delimiter=',') csv.writerows(data)
if use csv, can later parse , read file anywhere want. in sql data importing.
Comments
Post a Comment