合并csv文件python时出现编码错误

时间:2019-05-06 18:46:25

标签: python pandas encoding

运行代码时出现以下错误:

UnicodeDecodeError: 'utf8' codec can't decode byte 0xda in position 36: 
invalid continuation byte. Apparently there is an encoding error with the code. 

我试图将.encode扩展名添加到变量中,但是没有任何运气。

以下是我的代码:

import os
import glob
import pandas as pd

os.chdir("C://Procesos/Folder")
extension = 'csv'

all_filenames = [i for i in glob.glob('*.{}'.format(extension))]
combined_csv = pd.concat([pd.read_csv(f) for f in all_filenames ])
combined_csv.to_csv( "C://Procesos/Folder/combined_csv.csv", index=False, encoding='utf-8-sig')

0 个答案:

没有答案