I have a csv file Temp.csv that I am copying over to another csv file Final.csv using the following piece of code.
dirname = os.path.dirname(os.path.abspath(__file__))
csvfilename = os.path.join(dirname, 'Final.csv')
tempfile = os.path.join(dirname, 'Temp.csv')
with open(csvfilename, 'wb') as output_file:
writer = csv.writer(output_file, delimiter=',')
writer.writerow(["Title","This"])
writer.writerow([])
with open(tempfile, 'r') as data_file:
for line in data_file:
line = line.replace('\n', '')
row = line.split(",")
writer.writerow(row)
The last 5 lines of the code are going to write to the Final.csv file from column A. I want them to write to final.csv from column D. Also I have multiple columns in the Temp.csv file. What is the best solution for this? Using python 2.7.10.