跳过“ for line”循环中的第一行

时间:2020-01-23 10:28:54

标签: python-3.x csv

我有一种有效的方法来组合要修改的大型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)

0 个答案:

没有答案
相关问题