输入:csv文件。
样本数据id,name,gnd,address,second_name.
"100","xx","m","plot y zzzz city","zx
yddfe"
在输出:csv文件。在
^{pr2}$
在源文件中,最后一列的数据被分成两行,我想把它分成一行来加载数据。在
我试过:import csv
with open("out.csv","w") as fout:
with open("sample.csv")as f:
firsttline = ""
for line in f:
if not line.startswith('"'):continue
else:
line = line.rstrip('\n')
firstline = firstline + '\n'+ line
print >> fout, firstline
with open ("out.csv") as fin:
with open("out1.csv","w") as fout1:
for line in fin:
if not line.isspace():
fout1.write(line)
使用此代码后,我没有得到正确的记录计数。缺少一些列的数据。请帮帮我。在