I have a CSV file with 5 columns. Using Python, how can I delete the last column (header5 in the example)? Is there an easy way I\'m missing, or do I have to loop through al
Use the csv module. When writing out a row, use row[:-1] to chop off the last item:
import csv
with open(filename,"r") as fin:
with open(outname,"w") as fout:
writer=csv.writer(fout)
for row in csv.reader(fin):
writer.writerow(row[:-1])