Adding a column in a tab delimited txt file

Harald Massa cpl.19.ghum at
Fri Aug 22 22:30:56 CEST 2003

... 20 columns, now I need to add another column of zero at the 4th 
position and a column of zero at the 9th column position. What is the

import csv

reader = csv.reader(open("sample.csv"))
writer = csv.writer(open("sample2.csv","w")

for data in reader:

Maybe optimization with the list concatenation is possible. But first 
test, if it is not fast enough.

(csv is included with python 2.3, is available seperately in the internet 
for 2.2 also)


More information about the Python-list mailing list