在熊猫上使用多个定界符

时间:2019-09-13 17:06:34

标签: python pandas tabula

我正在使用tabula-py读取pdf文件,该表使用pandas DataFrame作为输出。但是我需要指定两个DataFrame分隔符:\r,

costs = tabula.read_pdf(
    url, 
    pages=1,
    pandas_options=dict(
        names=columns, 
        sep=r'\r|,', 
        engine='python'
    )
)

出现此错误:

CSVParseError: Error failed to create DataFrame with different column tables.
Try to set `multiple_tables=True`or set `names` option for `pandas_options`. 
, caused by ParserError('Expected 3 fields in line 7, saw 9. Error could possibly be due to quotes being ignored when a multi-char delimiter is used.')

0 个答案:

没有答案