精华内容
下载资源
问答
  • 怎么在文件中提取表格
    千次阅读
    2021-02-25 10:51:37

    目标

    将图片中的表格保存到excel。

    代码

            with open(picture, "rb") as f:
                img_data = f.read()
            img_base64 = b64encode(img_data)
            cred = credential.Credential(SecretId, SecretKey)  # ID和Secret从腾讯云申请
            httpProfile = HttpProfile()
            httpProfile.endpoint = "ocr.tencentcloudapi.com"
    
            clientProfile = ClientProfile()
            clientProfile.httpProfile = httpProfile
            client = ocr_client.OcrClient(cred, "ap-shanghai", clientProfile)
    
            req = models.TableOCRRequest()
            params = '{"ImageBase64":"' + str(img_base64, 'utf-8') + '"}'
            req.from_json_string(params)
            resp = client.TableOCR(req)
    
            ##提取识别出的数据,并且生成json
            result1 = loads(resp.to_json_string())
    
            rowIndex = []
            colIndex = []
            content = []
    	    ##按照行列写入字典,并把需要替换的字符替换
            for item in result1['TextDetections']:
                rowIndex.append(item['RowTl'])
                colIndex.append(item['ColTl'])
                item['Text'] = item['Text'].replace("\n", '')
                item['Text'] = item['Text'].replace(" ", '')
                item['Text'] = item['Text'].replace(",", '')
                item['Text'] = item['Text'].replace("¥", '')
                content.append(item['Text'])
    
            ##导出Excel
            ##ExcelWriter方案
            rowIndex = Series(rowIndex)
            colIndex = Series(colIndex)
    
            index = rowIndex.unique()
            index.sort()
    
            columns = colIndex.unique()
            columns.sort()
    
            data = DataFrame(index=index, columns=columns)
            for i in range(len(rowIndex)):
                data.loc[rowIndex[i], colIndex[i]] = sub("", "", content[i])
    	    ##保存成excel文件
            writer = ExcelWriter(match(".*\.",f.name).group()+"xlsx", engine='xlsxwriter')
            data.to_excel(writer, sheet_name='Sheet1', index=False, header=False)
            writer.save()
    

    总结

    1. 需要用到腾讯云的SDK,可以在官网申请开通。
    2. 不一定是表格,其它票据文档也可以用,改api就行,后续对json的处理会不同,但不复杂,类似。
    3. 保存的文件命名是以图片名命名。
    更多相关内容
  • 将要提取表格的pdf文件重命名为test.pdf,将exe放在test.pdf这个目录,双击即可将pdf所有表格提取到同一目录下的Result.xls文件中
  • TrapRange:一种提取PDF文件中的表内容的方法 资料来源: : 更新 从命令行运行。 键入java -jar traprange.latest.jar -h获得帮助,或查看文件test-command-line.sh示例 介绍 表数据结构是文档最重要的数据结构...
  • tabula-extractor, 从PDF文件中提取表格 Tabula提取器( 旧版本)注意:Deprecation Deprecation: 这是Tabula提取引擎的旧版。 希望集成补丁的新项目应该使用 Tabula Java ( 这个提取引擎的新Java版本),除非你喜欢...
  • 安装 1)RVM安装 sudo apt-get install curl ...a) 将一个 pdf 文件提取到一张 xls 工作表,每个标签有一个标签 Ruby提取阵列.rb b) 将一个 pdf 文件提取为多个 csv 文件(每个选项卡一个文件) Ruby提取数组Csv.
  • docx_python_process 从docx文件中批量提取图片表格内文字 pip安装: pip install python-docx
  • xlrd:从Microsoft Excel电子表格文件中提取数据的Python库
  • 快速提取PDF文件中表格

    千次阅读 2021-03-29 19:48:48
    使用Adobe Acrobat打开PDF文件,并将PDF表格转存到EXCEL

    首先使用Adobe Acrobat Pro DC打开PDF文件,选中表格中的内容。下图是两种选择方式。

    在这里插入图片描述

    在这里插入图片描述

    • 方案一
      右键,点击“将选中项目导出为(X)”,选择“*.xlsx”,点击保存。

    • 方案二(推荐)
      右键,点击“复制时包含格式(F)”,打开Excel直接进行粘贴即可。
      在这里插入图片描述

    展开全文
  • 文本,特别是表格文件中,将数值提取出来,生成数组。包括浮点和整型数字。处理的对象可以是excel或者是txt,以及ascii文件,其中的文本间隔符本程序默认是“;”,大家可以自行修改间隔符参数再使用。
  • pdf格式存在的,比如:论文,技术文档,标准文件,书籍等。pdf格式使机器提取信息格外困难。 pdf的文本和表格处理用...这个库GitHub上星600多,不过使用起来很方便, 效果也很好,可以满足对pdf信息的提取需求。
  • 基于python实现一键将word表格提取到excel文件中
  • 从NCBI下载CSV格式的Reference Gene Catalog后,提取所需列数的ID,并写入到TXT文本中,为后续批量下载基因序列做准备
  • 之前excel里面分析log数据,简直日了*了。 现在用python处理日志数据. 主要涉及 matplotlib,open和循环的使用。 日志内容大致如下 2016-10-21 21:07:59,787 [7 MainWindowForm]INFO: update time 136.6314 ...
  • 怎么提取pdf表格数据In this article, we talk about the challenges and principles of extracting tabular data from PDF docs. We also compare six software tools to find out how they perform their ...

    怎么提取pdf中的表格数据

    In this article, we talk about the challenges and principles of extracting tabular data from PDF docs. We also compare six software tools to find out how they perform their respective tasks of parsing PDF tables and getting data out of them.

    在本文中,我们讨论了从PDF文档中提取表格数据的挑战和原理。 我们还比较了六个软件工具,以了解它们如何执行各自的任务以解析PDF表并从中获取数据。

    为什么从PDF中提取表格数据是一个挑战 (Why It’s a Challenge to Extract Tabular Data from PDF)

    Today PDF is used as the basis of communication between companies, systems, and individuals. It is regarded as the standard for finalized versions of documents as it is not easily editable except in fillable PDF forms. Most popular use cases for PDF documents in the business environment are:

    今天,PDF用作公司,系统和个人之间进行交流的基础。 它被认为是文档定稿版本的标准,因为除了可填写的PDF表格外,它不容易编辑。 在业务环境中,PDF文档的最流行用例是:

    • Invoices

      发票
    • Purchase Orders

      订单
    • Shipping Notes

      运输注意事项
    • Reports

      报告书
    • Presentations

      简报
    • Price & Product Lists

      价格和产品清单
    • HR Forms

      人力资源表格

    The sheer volume of information exchanged in PDF files means that the ability to extract data from PDF files quickly and automatically is essential. Spending time extracting data from PDFs to input into third party systems can be very costly for a company.

    PDF文件中大量的信息交换意味着快速,自动地从PDF文件提取数据的能力至关重要。 花费时间从PDF提取数据以输入到第三方系统对于公司而言可能是非常昂贵的。

    The main problem is that PDF was never really designed as a data input format, but rather, it was designed as an output format ensuring that data will look the same at any device and be printed correctly. A PDF file defines instructions to place characters (and other components) at precise x,y coordinates. Words are simulated by placing some characters closer than others. Spaces are simulated by placing words relatively far apart. As for tables — you are right — they are simulated by placing words as they would appear in a spreadsheet.

    主要问题是PDF从来没有真正设计成数据输入格式,而是设计成输出格式,以确保数据在任何设备上看起来都一样并且可以正确打印。 PDF文件定义了将字符(和其他组件)放置在精确的x,y坐标处的指令。 通过将某些字符放置得比其他字符更近来模拟单词。 通过将单词相对分开放置来模拟空间。 至于表,您是对的,它们是通过像在电子表格中一样放置单词来模拟它们的。

    We see that the PDF format has no internal representation of a table structure, which makes it difficult to extract tables for analysis. Unfortunately, a lot of open data is stored in PDFs, which was not designed for tabular data in the first place.

    我们看到PDF格式没有表结构的内部表示,这使得提取表进行分析变得很困难。 不幸的是,许多开放数据存储在PDF中,而这些数据最初并不是为表格数据而设计的。

    Luckily, different tools for extracting data from PDF tables are available in the market. Being somewhat similar to each other, they have their own advantages and disadvantages. In this article, we compare the most popular software that can help get tabular data out of PDFs and present it in an easy-to-read, editable, and searchable format.

    幸运的是,市场上有多种用于从PDF表提取数据的工具。 它们彼此有点相似,但各有优缺点。 在本文中,我们将比较最流行的软件,该软件可以帮助从PDF中获取表格数据,并以易于阅读,可编辑和可搜索的格式显示它们。

    OCR:何时以及为什么使用它 (OCR: When and Why to Use It)

    Before choosing a tool, the first point is to understand what type of PDF files — text- or image-based — you will work with. It will impact on whether to use Optical Character Recognition (OCR) or not.

    在选择工具之前,首先要了解您将使用哪种类型的PDF文件(基于文本或图像)。 这将影响是否使用光学字符识别(OCR)。

    For example, we have a report generated as an output by a piece of software and imported in PDF format. Commonly, it is a text-based PDF.

    例如,我们有一个报告,它是由一个软件生成的输出,并以PDF格式导入。 通常,它是基于文本的PDF。

    If you work with image-based PDFs like scanned paper docs, or, for example, files captured by a digital camera — this is where OCR comes in. OCR enables machines to recognize written text or printed letters inside images. In other words, the technology helps to convert ‘text-as-an-image’ into an editable and searchable format.

    如果您使用基于图像的PDF(例如,扫描的纸张文档),或者使用数码相机捕获的文件,则可以使用OCR。OCR使机器可以识别图像中的文字或印刷字母。 换句话说,该技术有助于将“文本图像”转换为可编辑和可搜索的格式。

    Image for post
    Document scanned and converted into a text document using OCR
    使用OCR扫描文档并将其转换为文本文档

    o if your PDF is image-based, then the process of data extraction consists of two tasks: to recognize text and then recognize the table structure (i.e., how the text is placed in rows and columns). Some tools, like Amazon Textract, can complete both of them. But since text recognition is a separate task, it can be performed independently, with the help of pure OCR tools. There are dozens of them, but in this article, we will focus on the table structure recognition.

    o如果您的PDF是基于图像的,则数据提取过程包括两个任务:识别文本,然后识别表结构(即,文本在行和列中的放置方式)。 某些工具(例如Amazon Textract)可以完成这两个工具。 但由于文本识别是一项单独的任务,因此可以在纯OCR工具的帮助下独立执行。 它们有数十种,但是在本文中,我们将重点放在表结构识别上。

    从表中检测和提取数据的细节 (Nuances of Detecting and Extracting Data from Tables)

    Let’s assume that we have a text-based PDF document generated as an output by a piece of software. It contains tabular data, and we want to extract it and present in a digital format. There are two main ways to detect tables:

    假设我们有一个基于文本的PDF文档,它是由一个软件生成的输出。 它包含表格数据,我们希望将其提取并以数字格式显示。 检测表有两种主要方法:

    • Manually, when you detect column borders by eye and mark table columns by hands

      手动,当您用肉眼检测列边界并用手标记表格列时
    • Automatically, when you rely on program algorithms

      自动,当您依赖程序算法时

    Some tools offer either manual or automatic detection, while others combine both variants. From our experience, we can say that most of our clients’ cases require automatic recognition because they handle hundreds of documents with a slightly variable table structure. For example, columns’ width can differ not only between two documents but also on different pages inside one document. Therefore, if we mark each column in each table on each page by hand, it would take a lot of time and effort.

    一些工具提供手动或自动检测,而其他工具则结合了这两种变体。 根据我们的经验,我们可以说大多数客户的案例需要自动识别,因为他们处理的表结构略有变化的数百个文档。 例如,列的宽度不仅可以在两个文档之间不同,而且可以在一个文档内的不同页面上不同。 因此,如果我们在每个页面上手动标记每个表中的每一列,则将花费大量时间和精力。

    For our study, we created a sample one-page document covering all typical difficulties of data extraction caused by an ‘inconsistent’ table structure. Here is it:

    对于我们的研究,我们创建了一个样本的单页文档,其中涵盖了由“不一致”表结构引起的所有典型数据提取困难。 就这个:

    Image for post
    Sample document created for the study
    为研究创建的样本文件

    As you can see, in our sample document, we have multiple tables, and all of them have different widths of columns and inconsistent alignments. In such cases, manual detection can be tedious. For this reason, we are not going to use software that offers only manual table data detection. We choose an automatic way, and let’s see how good are algorithms for each of the tools.

    如您所见,在我们的示例文档中,我们有多个表,并且所有表都有不同的列宽和不一致的对齐方式。 在这种情况下,手动检测可能很乏味。 因此,我们将不使用仅提供手动表格数据检测的软件。 我们选择一种自动方式,让我们看看每种工具的算法效果如何。

    In addition to the table structure’s basic elements, we also deliberately included some ‘extra formatting’ that can potentially complicate the process of recognition:

    除了表结构的基本元素外,我们还故意包含一些“额外格式”,这些格式可能会使识别过程复杂化:

    • Multiple tables on a page — all of them should be detected

      页面上有多个表格-应该检测到所有这些表格
    • Non-tabular data: headers and page number

      非表格数据:标题和页码
    • The multiline text inside cells

      单元格内的多行文字
    • Table column & row spanning — merged cells

      表的列和行跨度—合并的单元格
    • Small table cell margins inside the table and between the table and the header

      表格内部以及表格和标题之间的小表格单元格边距

    PDF表提取库和工具的比较 (Comparison of PDF Table Extraction Libraries and Tools)

    From this study, you will learn about how six software tools perform their respective tasks of parsing PDF tables and how they stack up against each other. In the first part, we compare Tabula, PDFTron, and Amazon Textract.

    通过本研究,您将了解六个软件工具如何执行各自的解析PDF表的任务,以及它们如何相互堆叠。 在第一部分中,我们比较了Tabula,PDFTronAmazon Textract。

    Let’s see how libraries and tools mentioned above coped with this task of data recognition and extraction based on our sample document.

    让我们看看上面提到的库和工具如何根据我们的示例文档来完成数据识别和提取的任务。

    塔布拉 (Tabula)

    Tabula is a tool for liberating data tables locked inside PDF files. Tool overview:

    Tabula是用于释放锁定在PDF文件中的数据表的工具。 工具概述:

    • Type of software available: web application, requires simple local server setup

      可用软件类型: Web应用程序,需要简单的本地服务器设置

    • Platforms: Windows, MacOS, open source (GitHub, MIT Licence)

      平台: Windows,MacOS,开源(GitHub,MIT Licence)

    • Terms of use: free, open-source

      使用条款:免费,开源

    • Supported output formats: CSV, TSV, JSON

      支持的输出格式: CSV,TSV,JSON

    • Notes: Tabula only works on text-based PDFs, not scanned documents

      注意: Tabula仅适用于基于文本的PDF,不适用于扫描的文档

    After uploading our sample file and parsing data from it via Tabula, we got the following output:

    在上传示例文件并通过Tabula解析其中的数据之后,我们得到以下输出:

    Image for post
    Image for post
    Tabula: the result of detection of tables in the sample document
    表格:示例文档中表格的检测结果

    Zones marked in red are parts of the original file where Tabula detected tables. At this step, data recognition is captured correctly; all tables are detected, extraneous elements do not distort the result.

    红色标记的区域是Tabula检测到表的原始文件的一部分。 在此步骤中,数据识别已正确捕获。 所有表都被检测到,无关元素不会扭曲结果。

    But if we go further, we will see that the first row of the first and last rows of the last two tables is missing:

    但是,如果走得更远,我们将看到最后两个表的第一行和最后一行的第一行丢失了:

    Image for post
    Tabula’s Lattice method: preview of extracted tabular data
    Tabula的Lattice方法:预览提取的表格数据

    Tabula offers two options: two data extraction methods. The automatic detection method is Lattice. The result of its usage you can see above. If we try Stream, results become better; all data is extracted correctly without missing rows:

    Tabula提供了两种选择:两种数据提取方法。 自动检测方法是莱迪思。 您可以在上面看到其使用结果。 如果尝试Stream ,结果会更好; 正确提取所有数据而不会丢失行:

    Image for post
    Tabula’s Stream method: preview of extracted tabular data
    Tabula的Stream方法:预览提取的表格数据

    But using the Stream method, we face another problem: cells with multiline text are split into multiple table rows. It seems this variant is the best that we can get from Tabula.

    但是使用Stream方法,我们面临另一个问题:具有多行文本的单元格被拆分为多个表行。 看来这种变形是我们可以从Tabula获得的最好的变形。

    Summary: Tabula’s automatic detection method is not the best choice, so I don’t recommend relying on it. Both recognition methods provided by this tool have their own disadvantages. While data loss looks unacceptable in any case, split rows can be returned to their original state with additional processing — manually or with the script’s help.

    简介 :Tabula的自动检测方法不是最佳选择,因此我不建议依赖它。 此工具提供的两种识别方法都有其自身的缺点。 尽管在任何情况下数据丢失看起来都是不可接受的,但可以通过手动或在脚本的帮助下进行额外的处理,将拆分的行恢复为原始状态。

    PDFTron (PDFTron)

    PDFTron is software with multiple basic and advanced features that facilitate the manipulation of PDFs. Tool overview:

    PDFTron是具有多种基本和高级功能的软件,可简化对PDF的操作。 工具概述:

    • Type of software available: desktop app, web browser app, mobile app

      可用软件类型:桌面应用程序,Web浏览器应用程序,移动应用程序
    • Platforms: Android, iOS, Windows, Linux, MacOS

      平台:Android,iOS,Windows,Linux,MacOS
    • Terms of use: free trial period, pricing for licensing starts at $4000 annually

      使用条款:免费试用期,许可的起价为每年4000美元
    • Supported output formats: MS Word, SVG, HTML

      支持的输出格式:MS Word,SVG,HTML

    After uploading our sample file and parsing data from it via PDFTron, we got the following output:

    在上传示例文件并通过PDFTron解析了其中的数据之后,我们得到以下输出:

    Image for post
    PDFTron: the result of detection of tables in the sample document
    PDFTron:样本文档中表格的检测结果

    Red rectangles show the borders of detected tables. The number of tables and tabular data is recognized correctly, but headers of the third and fourth tables are captured as the table elements.

    红色矩形显示检测到的表格的边框。 可以正确识别表和表格数据的数量,但是将第三和第四表的标题捕获为表元素。

    If we convert the original PDF into HTML format using PDFTron, we’ll see that the headers named ‘CATEGORY 2’ and ‘CATEGORY 3’ are included as separate cells inside the table. Also, there are bugs with merged cells of the first table: the last two columns are merged as a larger one, and the second line of text is separated into a separate cell.

    如果使用PDFTron将原始PDF转换为HTML格式,则会看到名为“ CATEGORY 2”和“ CATEGORY 3”的标头作为单独的单元格包含在表中。 此外,第一个表的合并单元格也存在错误:最后两列合并为较大的单元格,第二行文本被分隔为单独的单元格。

    Image for post
    PDFTron: preview of extracted tabular data
    PDFTron:预览表格数据的预览

    Summary: In the output document we can see a piece of non-tabular data incorrectly included in the extraction result. It’s not a big problem since it can be purged after processing, manually, or with the script’s help. Also, I will not recommend this tool in cases when you have a lot of merged cells — they might be messed up.

    简介:在输出文档中,我们可以看到提取结果中错误地包含了一段非表格数据。 这不是一个大问题,因为可以在处理后,手动或在脚本的帮助下清除它。 另外,如果您有很多合并的单元格,则我不推荐使用此工具,因为它们可能会弄糟。

    亚马逊Textract (Amazon Textract)

    Amazon Textract is a service that automatically extracts text and data from scanned documents that go beyond simple optical character recognition (OCR) to identify, understand, and extract data from forms and tables. Tool overview:

    Amazon Textract是一项服务,可以自动从扫描的文档中提取文本和数据,而不仅仅是简单的光学字符识别(OCR)来识别,理解和提取表单和表格中的数据。 工具概述:

    • Type of software available: web application

      可用软件类型:Web应用程序
    • Platforms: any modern web browser, all processing goes ‘in the Cloud’

      平台:任何现代的Web浏览器,所有处理都在“云端”进行
    • Terms of use: several models (free, monthly subscriptions, cost-per-page model)

      使用条款:多种模式(免费,每月订阅,每页成本模式)
    • Supported output formats: raw JSON, JSON for each page in the document, text, key/values exported as CSV, tables exported as CSV.

      支持的输出格式:原始JSON,文档中每个页面的JSON,文本,以CSV格式导出的键/值,以CSV格式导出的表。

    After uploading our sample file and parsing data from it via Amazon Textract, we got the following result:

    在上传示例文件并通过Amazon Textract解析了其中的数据之后,我们得到了以下结果:

    Image for post
    Image for post
    Amazon Textract: the result of detection of tables in the sample document
    Amazon Textract:示例文档中表的检测结果

    Zones painted in gray are parts of the original file where Amazon Textract detected tables. As you can see, it didn’t recognize the first table on the page, detected two separate tables — the second and the third — as a single one, and also messed up the order of tables on the page.

    灰色区域是Amazon Textract检测到表的原始文件的一部分。 如您所见,它无法识别页面上的第一个表,将两个单独的表(第二个和第三个表)检测为单个表,并且还弄乱了页面上表的顺序。

    Regarding the data inside the cells, the extraction result is quite satisfying with some exceptions:

    关于单元内的数据,提取结果非常令人满意,但有一些例外:

    • Missing the data of the first table in the extraction result

      提取结果中缺少第一个表的数据
    • Header string ‘CATEGORY 3 is included as a part of table in the extraction result

      标头字符串“ CATEGORY 3”作为表的一部分包含在提取结果中
    Image for post
    Image for post
    Amazon Textract: preview of extracted tabular data
    Amazon Textract:预览表格数据的预览

    Summary: Amazon Textract looks to be the less suitable tool for data extraction applied to this particular case. A large amount of data loss, messed order of tables, and non-tabular data in the output document. The main advantage of Amazon Textract compared to all other tools is OCR, so that you can extract tabular data from images or image-based PDFs. In the case of text-based PDF, I would recommend choosing another tool.

    简介: Amazon Textract似乎不太适合应用于此特定案例的数据提取工具。 输出文档中大量数据丢失,表顺序混乱以及非表格数据。 与所有其他工具相比,Amazon Textract的主要优势是OCR,因此您可以从图像或基于图像的PDF中提取表格数据。 对于基于文本的PDF,我建议选择其他工具。

    Here is the first part of the article ‘How to Extract Tabular Data from PDF. In the second part, which is coming soon, we will analyze three more popular solutions for extracting and converting data from PDF and prepare a big сomparison table where each tool is rated according to the specific criteria. Follow UpsilonIT’s blog not to miss the great content!

    这是文章“如何从PDF提取表格数据”的第一部分。 即将推出 的第二部分中 ,我们将分析另外三种从PDF提取和转换数据的流行解决方案,并准备 一张巨大的比较表 ,其中每个工具均根据特定标准进行评级。 关注UpsilonIT的博客,不要错过精彩的内容!

    翻译自: https://medium.com/@upsilon_it/how-to-extract-tabular-data-from-pdf-part-1-16cc3a29fcfa

    怎么提取pdf中的表格数据

    展开全文
  • python自动办公-23 一键将word表格提取到excel文件中.zip源码python项目实例源码打包下载python自动办公-23 一键将word表格提取到excel文件中.zip源码python项目实例源码打包下载python自动办公-23 一键将...
  • 可以一键提取目录下所有文件(免积分下载),子目录里面的也可以,直接按顺序输出到Excel表格 功能菜单如下: ┌───获取当前目录所有文件文件名───┐   1 获取同级目录文件名字    2 深入子目录获取全部...
  • 需求:提取word的表格,并保存excel pip install python-docx Test.docx: from docx import Document from openpyxl import Workbook from docx.shared import Cm #Cm模块,用于设定图片尺寸大小 #word中文...

    需求:一些常用的对word的操作和提取word的表格,并保存在excel中

    pip install python-docx
    
    from docx import Document
    from openpyxl import Workbook
    from docx.shared import Cm  #Cm模块,用于设定图片尺寸大小
    #word中文档成为Document,每段内容称为Paragraph,每个段中不同部分称为Run(颜色、字体、粗细、斜体等不同就是不同的文字块)
    doc = Document(r"Test.docx")
    
    #提取文字和文字块儿
    print(doc.paragraphs)
    for paragraph in doc.paragraphs:
        print(paragraph.text)
    
    paragraph = doc.paragraphs[0]
    runs = paragraph.runs
    print(runs)
    for run in paragraph.runs:
        print(run.text)
    paragraph = doc.paragraphs[3]
    runs = paragraph.runs
    print(runs)
    for run in paragraph.runs:
        print(run.text)
    
    list1 = [["name","sex","Provin"],["violet1","女","日本省"],["violet2","女","日本省"],["violet3","女","日本省"],["violet4","女","日本省"]]
    list2 = [["name","sex","Provin"],["violet5","女","日本省"],["violet6","女","日本省"],["violet7","女","日本省"]]
    #向Word文档写入内容
    paragraph1 = doc.add_paragraph("新加段落1")
    paragraph2 = doc.add_paragraph("新加段落2")
    paragraph3 = doc.add_paragraph()
    paragraph3.add_run("加粗文字块").bold = True
    paragraph3.add_run(",普通文字块, ")
    paragraph3.add_run("斜体文字块").italic = True
    doc.add_page_break()    #添加分页
    #doc.add_picture(r"E:\PycharmProjects\SpiderTest\violet.png",width=Cm(5),height=Cm(5))
    table1 = doc.add_table(rows=5,cols=3)
    for row in range(5):
        cells = table1.rows[row].cells
        for col in range(3):
            cells[col].text = str(list1[row][col])
    doc.add_paragraph("-----------------------------------------------------------")
    table2 = doc.add_table(rows=4,cols=3)
    for row in range(4):
        cells = table2.rows[row].cells
        for col in range(3):
            cells[col].text = str(list2[row][col])
    doc.save(r"Test2.docx")
    
    
    #提取word中的表格,并保存在excel
    t0 = doc.tables[0]
    workbook = Workbook()
    sheet = workbook.active
    for i in range(len(t0.rows)):
        list1 = []
        for j in range(len(t0.columns)):
            print("元素:"+t0.cell(i,j).text)
            list1.append(t0.cell(i,j).text)
        print("表格每一行list:", list1)
        sheet.append(list1)
    workbook.save(filename = r"TestByWord.xlsx")
    

    处理后的结果:

    TestByWord.xlsx:
    在这里插入图片描述

    展开全文
  • Python 提取 PDF 表格数据

    千次阅读 2021-06-12 00:16:51
    PDF 表格数据,使用 Python 提取,使用的框架是 pdfplumber 或 camelot 。
  • 如何快速提取CAD图纸表格数据第一步:打开CADCAD命令行输入"Li"。”对象“,点选需要提标的多段线。回车。第二步:将CAD文本框据复制到Excel。选中文本框的有效数据”Ctrl C“,打开的Excel”Ctrl V“。第...
  • Delphi开发的小程序可以获取html 网页里面的表格中的内容数据 使用WebBrowser控件,解决打开网页乱码,自动转码
  • 用Python提取pdf文件中表格数据

    千次阅读 2020-12-29 05:53:28
    访问http://www.wuhanstring.com/uploads/5_aboutus/爬虫俱乐部-用户问题登记表.docx(复制到浏览器)下载爬虫俱乐部用户问题登记表并按要求填写后发送至邮箱statatraining@163.com,我们会及时为您解答哟~爬虫俱乐部...
  • Java读取Word表格(Excel),并导出文件为Excel
  • 批量提取文件标题.bat

    2020-05-14 11:23:27
    该资源可瞬间提取选取文件夹内的所有文件,并将文件名写入到EXCEL表格中,方便日常开展工作,提高工作效率。
  • 批量提取pdf表格中内容到excel 使用方法:双击启动软件,选择要提取PDF支持多选,回车运行程序。提取好内容自动生成excel文件与pdf文件同目录下。
  • M2TEX 循环遍历目录的所有 m 文件并从中提取注释部分。 简短的一行描述用于创建一个 Contents.m,可以用 MATLAB 的帮助功能显示。 一个 LaTeX 文件是用一个表格创建的,表格包含简短的描述,部分的 m 文件标题...
  • python提取pdf文件中表格

    千次阅读 2019-10-24 18:37:51
    做pdf文字抽取时,pdfplumber会与pdfminer3k有版本冲突,而且接口的封装性、抽取效果也没有pdfplumber好,所以强烈建议使用pdfplumber,抛弃pdfminer3k。 1、工具 pdfplumber pip install pdfplumber 2、调用...
  • 利用此方法针对大量的报名表进行信息提取~ 安装工具包 pip install python-docx 表格信息 代码 注意读取的EXCEL文件只能是docx后缀的噢~若文件太多可利用以下方法批量转化 import os import docx import xlwt ...
  • python提取pdf表格,并保存到excel

    千次阅读 2022-04-05 22:29:46
    python提取pdf表格,并保存到excel
  • 使用方法: 1.打开软件 2.打开一个Excel空白文件并最小...8.这时你会发现第二步骤新建的Excel文件中已经出现了框选住的表格的Excel版本。 就是这么简单,好用得话评个分吧,第一次发帖,有不对的地方大家多包涵。
  • 数据库提取表格

    2014-01-08 11:30:30
    实现从数据库中提取中数据,方便使用,谢谢大家参考下载并提出宝贵意见

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 67,715
精华内容 27,086
关键字:

怎么在文件中提取表格