my test.csv
1,1,2
2,1,3
3,1,4
my test2.csv
2,3
2,3
2,3
How can i make the output.csv:
1,1,2,2,3
2,1,3,2,3
3,1,4,2,3
so to combine two csv files to one?
Here's my code
import csv, os, sys
with open('test.csv', 'rb') as input, open('output.csv', 'wb') as output, open ('test2.csv', 'rb') as input2:
reader = csv.reader(input, delimiter = ',')
reader2 = csv.reader(input2, delimiter = ',')
writer = csv.writer(output, delimiter = ',')
all = []
header = next(reader)
all.append(header)
count = 0
for row,row2 in reader and reader2:
count += 1
while count:
all.append(row+row2)
break
writer.writerows(all)
Obviously this doesn't work, but does anybody understand what I'm going for?