python-3.x - 如何使用 camelot 从 PDF 文件中提取表后获取列名?我是新手
问题描述
简而言之,我正在执行此步骤。
tables = camelot.read_pdf(doc_file)
tables[0].df
我tables[0].df.columns
用来从提取的表中获取列名。
但它没有给出列名。
解决方案
Camelot 提取的表没有字母列名。
tables[0].df.columns
例如,对于三列表返回:
RangeIndex(start=0, stop=3, step=1)
相反,您可以尝试读取第一行并从中获取列表:tables[0].df.iloc[0].tolist()
. 输出可能是:
['column1', 'column2', 'column3']
推荐阅读
- c# - 过滤集合导航属性
- python - 如果我们使用 DictCursor,pymysql 中的键是如何定义的?
- google-drive-api - 上传的 html 打开为 Google 文档缺少图像
- javascript - Usung java 脚本如何将变量传递给 $_SESSION[''] 对象?
- python - 构建适用于测试和运行代码的 python3 代码和导入的正确方法是什么?
- c++ - 无法在 Visual Studio 2017 中显式专门化
- html - 无法使用 HTML on Rails 应用程序链接到图像
- c++11 - 需要在自定义向量中找到最高的非重复数
- python - Python循环的时间复杂度
- swift - 快速设置字典时出现错误