我有一种有效的方法来组合要修改的大型CSV文件(无需读入内存),以便跳过标题行。有没有办法跳过标头行(类似于for line in infile if not the first line
,但不读入内存)?
filenames = os.listdir(localdir)
print("concatenating files %s"%(sorted((filenames))))
with open(localdir+outfile+'.csv', 'w') as outfile:
for fname in filenames:
with open(localdir+fname) as infile:
for line in infile:
outfile.write(line)