有人帮我一个程序,这样我就可以将PDF文件从该格式转换为csv,但他们没有指定编码类型,下面是代码:
import os
import glob
import tabula
path="/Users/username/Downloads/"
for filepath in glob.glob(path+'*.pdf'):
name=os.path.basename(filepath)
tabula.convert_into(input_path=filepath,
output_path=path+name+".csv",
pages="all")
如何获得要转换为utf-8
或cp1252
编码的CSV文件
谢谢你帮忙
我得到的错误
1条答案
按热度按时间hwazgwia1#
您可以使用
chardet
库获取tabula生成的文件的结果编码,然后使用pandas
将其转换为您想要的编码。