withopen(r'C:\Users\sheet1.csv','r')as f,open(r'C:\2\sheet1.csv','w')as f1:next(f)# skip header linefor line in f:
f1.write(line)
路径部分为文件的绝对路径。
因为有48个csv文件需要修改,因此需要写一个for循环。
for i in range(1,49):
with open(r'C:\Users\sheet%d.csv'%i, 'r') as f,open(r'C:\2\sheet%d.csv'%i, 'w') as f1:
next(f)# skip header linefor line in f:
f1.write(line)
for i inrange(1,49):withopen(r'C:\Users\csv\sheet%d.csv'%i,'r', encoding="utf-8")as f,open(
r'C:\Users\csv\2\sheet%d.csv'%i,'w', encoding="utf-8")as f1:next(f)# skip header linefor line in f:
f1.write(line)