every body. I have some data like the following:
data = [ ['234','123','145','134','156'],['12','67895','12345','1234'] ]
I want to write these data into a csv file in such a way that "aid,pid" are the column title. The first element of each sub-list is the "aid" column,the rest are the "pid".Now I want to write the pid with a tab character like the following.
aid,pid
234,123 145 134 156
12,67895 12345 1234
Here is my sample code
import csv
data =[ ['234','123','145','134','156'],['12','67895','12345','1234'] ]
valid_result = open('./result/valid_result.csv','wb')
writer = csv.writer(valid_result,delimiter = ',',dialect = 'excel-tab')
header = ['aid','pid']
writer.writerow(header)
for record in data:
writer.writerow(record)
Is there any solution in python?