我确实有一个 CSV 文件行,如下所示
22727176549389059,1917,6544,**91999926,266392261**,53972147,2131,Sun Apr 28 21:00:44 PDT 2013
我想在第 4 列和第 5 列之间添加一个新列。我怎样才能做到这一点?
22727176549389059,1917,6544,**91999926**,new column,**266392261**,53972147,2131,Sun Apr 28 21:00:44 PDT 2013
我知道如何在最后追加。但这无济于事...
import csv
all = []
with open('fileinput','rU') as csvinput:
reader = csv.reader((line.replace('\0','') for line in csvinput), delimiter=',')
line = 0;
try:
for row in reader:
# row.append('')
if '\0' in row: continue
if not row: continue
row.append('#3')
all.append(row)
except csv.Error, e:
print 'Error'