利用pandas读取和写入csv
import pandas import datetime import numpy as np df = pandas.read_csv('abc.csv', index_col=0,encoding ='utf-8') dfNew = pandas.read_csv('writeNew.csv', index_col=0,encoding ='utf-8') j = 0 for i in df.iloc: new=pandas.DataFrame({'字段1':i.name, '字段2':'XXXX', '字段3':'XXXX', '字段4':'时间'}, index=[1]) dfNew=dfNew.append(new,ignore_index=True) j=j+1 if (j%10000 == 0): print(j) dfNew.to_csv("test.csv",quoting=1,index=False,sep=',') print('成功')
写入CSV的时候,用【quoting=1】,写入CSV的数据会加上双引号