Kev*_*ang 6 python pdf tabula-py
我尝试使用Python包tabula-py来读取pdf中的表格,似乎pdf表格单元格中的换行符会将原始单元格中的内容分成多个单元格。
我尝试搜索各种python包来解决这个问题。看来 tabula-py 是将 pdf 表转换为 pandas 数据的最稳定的包。但是,如果这个问题无法解决,我必须求助于在线服务,这将为我提供理想的excel输出。
from tabula import read_pdf
df=read_pdf("C:/Users/Desktop/test.pdf", pages='all')
Run Code Online (Sandbox Code Playgroud)
我期望 pdf 表可以用这个正确转换。
您可以使用值为“True”的“电子表格”选项来省略由换行符引起的多行 NAN 值。
\n\nimport tabula\n\n# Read pdf into DataFrame\ndf = tabula.read_pdf("FDA EPC Text Phrases (updated March 2018.pdf", pages=\'all\', spreadsheet=True)\nprint(df)\n#print(df[\'Active Moiety Name\'])\n#print(df[\'FDA Established Pharmacologic Class\\r(EPC) Text Phrase\\rPLR regulations require that the following\\rstatement is included in the Highlights\\rIndications and Usage heading if a drug is a\\rmember of an EPC [see 21 CFR\\r201.57(a)(6)]: \xe2\x80\x9c(Drug) is a (FDA EPC Text\\rPhrase) indicated for [indication(s)].\xe2\x80\x9d For\\reach listed active moiety, the associated\\rFDA EPC text phrase is included in this\\rdocument. For more information about how\\rFDA determines the EPC Text Phrase, see\\rthe 2009 "Determining EPC for Use in the\\rHighlights" guidance and 2013 "Determining\\rEPC for Use in the Highlights" MAPP\\r7400.13.\'])\nRun Code Online (Sandbox Code Playgroud)\n\n输出:
\n\n1758 ziconotide N-type calcium channel antagonist \n1759 zidovudine HIV nucleoside analog reverse transcriptase in... \n1760 zileuton 5-lipoxygenase inhibitor \n1761 zinc cation copper absorption inhibitor \n1762 ziprasidone atypical antipsychotic \n1763 zoledronic acid bisphosphonate \n1764 zoledronic acid anhydrous bisphosphonate \n1765 zolmitriptan serotonin 5-HT1B/1D receptor agonist (triptan) \n1766 zolmitriptan serotonin 5-HT1B/1D receptor agonist (triptan) \n1767 zolpidem gamma-aminobutyric acid (GABA) A agonist \n1768 zonisamide antiepileptic drug (AED) \nRun Code Online (Sandbox Code Playgroud)\n