Extracts tables from .docx files and saves them as csv or xlsx
Project description
Usage: docx2csv [OPTIONS] FILENAME
docx to csv convertor (http://github.com/ivbeg/docx2csv) Extracts tables from DOCX files as CSV or XLSX.
Use command: “docx2csv convert <filename>” to run extraction. It will create files like filename_1.csv, filename_2.csv for each table found.
- Options:
- --format TEXT
Output format: CSV, XLSX
- --singlefile TEXT
Outputs single XLS file with multiple sheets: True or False
- --sizefilter INTEGER
Filters table by size number of rows
- --help
Show this message and exit.
Examples
docx2csv –format csv –sizefilter 3 CP_CONTRACT_160166.docx
Extracts tables from file CP_CONTRACT_160166.docx with number of rows > 3 and saves results as CSV files.
Code
- Function “extract_tables” returns list of tables from docx file and function “extract” extracts tables as xlsx, xls or csv file. If ‘csv’ file selected you need to specify single file csv or multiple files
>>> from docx2csv import extract_tables, extract >>> tables = extract_tables('some_file.docx')
returns list of tables >>> extract(filename=’some_file.docx’, format=”xlsx”, output=’some_file.xlsx’) saves all tables from some_file.docx to some_file.xlsx
>>> extract(filename='some_file.docx', format="csv", singlefile=False) saves all tables from some_file.docx to some_file_1.csv, some_file_2.csv and etc.
Requirements
Acknowledgements
Thanks to Vsevolod Oparin (https://www.facebook.com/vsevolod.oparin) for optimized “extract_table” code
History
0.1.1 (2022-01-30)
Fixed requirements.txt and setup.py requirements
0.1.0 (2018-01-14)
First public release on PyPI and updated github code
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file docx2csv-0.1.1.tar.gz
.
File metadata
- Download URL: docx2csv-0.1.1.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4451df018c4e5d694e726d71f9564fce57010cff190a783ad36eeef07eaa6b8 |
|
MD5 | c2dfcff6a8af9728af45f25bb9b6bacd |
|
BLAKE2b-256 | 3468a1749a16d1d6f414eea13aec4f264eff840891cebcd66a9adc1f49656696 |