Metadata-Version: 2.4
Name: docx2csv
Version: 0.1.4
Summary: Extracts tables from .docx files and saves them as csv or xlsx
Author-email: Ivan Begtin <ivan@begtin.tech>
License: BSD-3-Clause
Project-URL: Homepage, https://github.com/ivbeg/docx2csv
Keywords: docx,converter,tables
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: click>=8.1.6
Requires-Dist: openpyxl>=3.1.2
Requires-Dist: python-docx>=0.8.11
Provides-Extra: xls
Requires-Dist: xlwt>=1.3.0; extra == "xls"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: flake8; extra == "dev"
Dynamic: license-file

# docx2csv

Extracts tables from .docx files and saves them as CSV, TSV, XLSX, or JSON.

[![CI](https://github.com/ivbeg/docx2csv/actions/workflows/ci.yml/badge.svg)](https://github.com/ivbeg/docx2csv/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/docx2csv.svg)](https://pypi.org/project/docx2csv/)
[![Python](https://img.shields.io/pypi/pyversions/docx2csv.svg)](https://pypi.org/project/docx2csv/)

## Installation

```bash
pip install docx2csv
```

For XLS (Excel 97) output support:

```bash
pip install docx2csv[xls]
```

## Quick Start

### Command Line

```bash
# Extract all tables as separate CSV files
docx2csv extract document.docx

# Extract as XLSX
docx2csv extract document.docx --format xlsx

# Extract as single CSV file with all tables
docx2csv extract document.docx --format csv --singlefile

# Filter tables by minimum row count
docx2csv extract document.docx --sizefilter 3

# Specify output location
docx2csv extract document.docx --output results.csv

# Analyze a document (list tables without extracting)
docx2csv analyze document.docx
```

### Python API

```python
from docx2csv import extract_tables, extract, analyze

# Get table data as Python objects
tables = extract_tables('document.docx')
for table in tables:
    print(f"Table {table['id']}: {table['num_rows']} rows x {table['num_cols']} cols")
    for row in table['data']:
        print(row)

# Extract to file
extract('document.docx', format='xlsx', output='output.xlsx')

# Analyze document structure
info = analyze('document.docx')
```

## Output Formats

| Format | Extension | Description |
|--------|-----------|-------------|
| CSV    | `.csv`    | Comma-separated values |
| TSV    | `.tsv`    | Tab-separated values |
| XLSX   | `.xlsx`   | Excel 2007+ (via openpyxl) |
| XLS    | `.xls`    | Excel 97 (requires `pip install docx2csv[xls]`) |
| JSON   | `.json`   | Structured JSON with metadata |

## Requirements

- [click](https://github.com/pallets/click)
- [python-docx](https://github.com/python-openxml/python-docx)
- [openpyxl](https://openpyxl.readthedocs.io/)

## Contributing

Contributions are welcome! Every little bit helps.

1. Fork the repo on GitHub
2. Clone your fork: `git clone https://github.com/your-username/docx2csv.git`
3. Create a branch: `git checkout -b name-of-your-bugfix-or-feature`
4. Make your changes and add tests
5. Run tests: `pytest`
6. Commit and push: `git commit -m "Your message" && git push origin your-branch`
7. Submit a pull request

## Credits

- **Ivan Begtin** - Author and maintainer
- **Vsevolod Oparin** - Optimized table extraction code

## License

BSD 3-Clause License. See [LICENSE](LICENSE) for details.
