gpt4 book ai didi

python - 将表格分隔符更改为另一个字符

转载 作者:太空宇宙 更新时间:2023-11-03 20:17:06 24 4
gpt4 key购买 nike

我需要从 pdf 中捕获一些数据并输入到 Excel 文件中,但要创建宏来组织单元格,我需要“,”以外的字符。因为某些值(value)数据需要“,”来表示分。有任何想法吗 ? (像“/”或“-”这样的字符就可以解决问题)

当我将 pdf 转换为 csv 时,所有数据都位于一个单元格中,这就是我需要使用宏的原因。 How my data is organized into excel

from tabula import read_pdf
from tabula import convert_into
convert_into("B.pdf", "BBBBB.csv", output_format="csv", pages=1,coding = 'latin-1',stream=True, guess = False ,
area = (306.9,253,379,570),
columns = (347,399.1,443.4,481.6,514.3,543.5,572))

最佳答案

如果您想继续使用convert_into,您可以设置output_format="tsv",它将转换为制表符分隔格式的表格。 https://tabula-py.readthedocs.io/en/latest/tabula.html#tabula.wrapper.convert_into除此之外,您可以使用 read_csv 转换为 DataFrame,然后使用 df.to_csv 设置分隔符。

关于python - 将表格分隔符更改为另一个字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58383642/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com