aip格式转化为pdf_python提取pdf文档中的表格数据、svg格式转换为pdf
提取pdf文件中的表格數(shù)據(jù)原文鏈接
https://www.analyticsvidhya.com/blog/2020/08/how-to-extract-tabular-data-from-pdf-document-using-camelot-in-python/
另外還參考了這篇文章
https://camelot-py.readthedocs.io/en/master/
實現(xiàn)提取pdf文檔中的表格數(shù)據(jù)需要使用camelot模塊?
這個模塊可以直接使用pip進行安裝
pip?install?"camelot-py[cv]"用到的pdf示例文件可以直接在原文鏈接處下載
http://gstcouncil.gov.in/sites/default/files/gst-revenue-collection-march2020.pdf
第一步是讀入pdf文件
import?camelottables?=?camelot.read_pdf('gst-revenue-collection-march2020.pdf',?flavor='stream',?pages='0-3')
這里flavor參數(shù)的作用暫時還不知道?
如果表格跨頁需要指定pages參數(shù)
tablestables[2]
tables[2].df
tables可以返回解析獲得的表格數(shù)量?
tables[2]獲取指定的表格?
tables[2].df將表格數(shù)據(jù)轉(zhuǎn)換成數(shù)據(jù)框
pandas 中兩個數(shù)據(jù)框按照行合并需要用到append()方法
aa?=?{"A":[1,2,3],"B":[4,5,6]}bb?=?{"A":[4],"B":[7]}
import?pandas?as?pd
a?=?pd.DataFrame(aa)
b?=?pd.DataFrame(bb)
a.append(b)
SVG格式轉(zhuǎn)換為pdf格式原文鏈接
https://www.tutorialexample.com/a-simple-guide-to-python-convert-svg-to-pdf-with-svglib-python-tutorial/
實現(xiàn)這個功能需要使用到的是svglib這個庫,直接使用pip安裝
pip?install?svglibsvg轉(zhuǎn)換為pdf格式代碼
from?svglib.svglib?import?svg2rlgfrom?reportlab.graphics?import?renderPDF
drawing?=?svg2rlg("home.svg")
renderPDF.drawToFile(drawing,?"file.pdf")
歡迎大家關(guān)注我的公眾號
小明的數(shù)據(jù)分析筆記本
總結(jié)
以上是生活随笔為你收集整理的aip格式转化为pdf_python提取pdf文档中的表格数据、svg格式转换为pdf的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 家人不知道已故人有存款,银行会告知吗?这
- 下一篇: dellmmkb.exe是什么进程 de