I am trying to write a python script that writes data from one csv file into another csv file that is structured differently
I am currently only able to just duplicate the data in in the structure of the source file.
!/usr/bin/env python3
#imports csv module
import csv
#opens file and reads
out=open("forecast_test.csv","rb")
data=csv.reader(out)
with open('new_data.csv', 'w') as new_data:
csv_writer = csv.writer(new_data)
for line in data:
csv_writer.writerow(line)
print (line)
The structure of the source file is below
id,
123,
435,
765,
I want my script to write it to a csv file that is structured like below
id, id2, id3
123, 435, 765