docviz-python


Namedocviz-python JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
SummaryA Python library for extracting and analyzing content from any documents, supporting batch and selective extraction, custom configuration, and multiple output formats.
upload_time2025-08-15 14:16:59
maintainerNone
docs_urlNone
authorfresh-milkshake
requires_python>=3.10
licenseMIT License Copyright (c) 2025 fresh-milkshake Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords pdf document analysis extraction scientific papers batch processing
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            > [!Caution]
> This project is in active development. The API is subject to change and breaking changes may occur. Package might not work until 1.5.0 release.


<div align="left">
  <img src="https://raw.githubusercontent.com/fresh-milkshake/docviz/refs/heads/main/assets/header_long.svg" alt="docviz" width="100%">
  
  ![python](https://img.shields.io/badge/python-3.10+-141414.svg)
  [![version](https://img.shields.io/pypi/v/docviz-python?color=141414&label=version)](https://pypi.org/project/docviz-python/)
  ![License](https://img.shields.io/badge/License-MIT-141414.svg)
</div>


## Overview

**Extract content from documents easily with Python.**

- Extract from PDFs and other formats
- Process one or many files
- Choose what to extract (tables, text, etc.)
- Export results to JSON, CSV, Excel
- Simple and flexible API

## 📦 Installation

```bash
pip install docviz-python
```

## Quick Start

### Basic Usage

```python
import asyncio
import docviz

async def main():
    # Create a document instance
    document = docviz.Document("path/to/your/document.pdf")
    
    # Extract all content
    extractions = await document.extract_content()
    
    # Save results
    extractions.save("results", save_format=docviz.SaveFormat.JSON)

asyncio.run(main())
```

### Synchronous Usage

```python
import docviz

document = docviz.Document("path/to/your/document.pdf")
extractions = document.extract_content_sync()
extractions.save("results.json", save_format=docviz.SaveFormat.JSON)
```

## Code Examples

### Batch Processing

```python
import docviz
from pathlib import Path

# Process all PDF files in a directory
pdf_directory = Path("data/papers/")
output_dir = Path("output/")
output_dir.mkdir(exist_ok=True)

pdfs = pdf_directory.glob("*.pdf")
documents = [docviz.Document(str(pdf)) for pdf in pdfs]
extractions = docviz.batch_extract(documents)

for ext in extractions:
    ext.save(output_dir, save_format=[docviz.SaveFormat.JSON, docviz.SaveFormat.CSV])
```

### Selective Extraction

```python
import docviz

document = docviz.Document("path/to/document.pdf")

# Extract only specific types of content
extractions = document.extract_content(
    includes=[
        docviz.ExtractionType.TABLE,
        docviz.ExtractionType.TEXT,
        docviz.ExtractionType.FIGURE,
        docviz.ExtractionType.EQUATION,
    ]
)

extractions.save("selective_results.json", save_format=docviz.SaveFormat.JSON)
```

### Custom Configuration

```python
import docviz

# Configure extraction settings
config = docviz.ExtractionConfig(
    extraction_type=docviz.ExtractionType.ALL,
    extraction_config=docviz.ExtractionConfig(
        extraction_type=docviz.ExtractionType.ALL,
    ),
)

document = docviz.Document("path/to/document.pdf", config=config)
extractions = document.extract_content()
extractions.save("configured_results.json", save_format=docviz.SaveFormat.JSON)
```

### Streaming Processing

```python
import docviz

document = docviz.Document("path/to/large_document.pdf")

# Process document in chunks to save memory
for chunk in document.extract_streaming(chunk_size=10):
    # Process each chunk (10 pages at a time)
    chunk.save(f"chunk_{chunk.page_range}.json", save_format=docviz.SaveFormat.JSON)
```

### Progress Tracking

```python
import docviz
from tqdm import tqdm

document = docviz.Document("path/to/document.pdf")

# Extract with progress bar
with tqdm(total=document.page_count, desc="Extracting content") as pbar:
    extractions = document.extract_content(progress_callback=pbar.update)

extractions.save("progress_results.json", save_format=docviz.SaveFormat.JSON)
```

### Data Analysis Integration

```python
import docviz
import pandas as pd

document = docviz.Document("path/to/document.pdf")
extractions = document.extract_content()

# Convert to pandas DataFrame for analysis
df = extractions.to_dataframe()

# Basic analysis
print(f"Total tables extracted: {len(df[df['type'] == 'table'])}")
print(f"Total figures extracted: {len(df[df['type'] == 'figure'])}")

# Save as Excel with multiple sheets
with pd.ExcelWriter("analysis_results.xlsx") as writer:
    df.to_excel(writer, sheet_name="All_Content", index=False)
    
    # Separate sheets by content type
    for content_type in df["type"].unique():
        type_df = df[df["type"] == content_type]
        type_df.to_excel(writer, sheet_name=f"{content_type.capitalize()}", index=False)
```

## 🔧 API Reference

### Core Classes

#### `Document`
Main class for document processing.

```python
document = docviz.Document(
    file_path: str,
    config: Optional[ExtractionConfig] = None
)
```

#### `ExtractionConfig`
Configuration for content extraction.

```python
config = docviz.ExtractionConfig(
    extraction_type: ExtractionType = ExtractionType.ALL,
    # Additional configuration options
)
```

#### `ExtractionType`
Enumeration of extractable content types:
- `TEXT` - Plain text content
- `TABLE` - Tabular data
- `FIGURE` - Images and figures
- `EQUATION` - Mathematical equations
- `ALL` - All content types

#### `SaveFormat`
Supported output formats:
- `JSON` - JavaScript Object Notation
- `CSV` - Comma-separated values
- `EXCEL` - Microsoft Excel format


## 📄 License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

---

<div align="center">
  <p style="background-color:rgb(22, 22, 22); padding: 10px; border-radius: 10px;">Made with ❤️ by <a href="https://github.com/fresh-milkshake">fresh-milkshake</a></p>
</div>


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "docviz-python",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "pdf, document analysis, extraction, scientific papers, batch processing",
    "author": "fresh-milkshake",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/31/18/717878be9d107c2fea3cfde69269c085fdd2a8cf5b0e31a22343f5549c69/docviz_python-0.2.0.tar.gz",
    "platform": null,
    "description": "> [!Caution]\r\n> This project is in active development. The API is subject to change and breaking changes may occur. Package might not work until 1.5.0 release.\r\n\r\n\r\n<div align=\"left\">\r\n  <img src=\"https://raw.githubusercontent.com/fresh-milkshake/docviz/refs/heads/main/assets/header_long.svg\" alt=\"docviz\" width=\"100%\">\r\n  \r\n  ![python](https://img.shields.io/badge/python-3.10+-141414.svg)\r\n  [![version](https://img.shields.io/pypi/v/docviz-python?color=141414&label=version)](https://pypi.org/project/docviz-python/)\r\n  ![License](https://img.shields.io/badge/License-MIT-141414.svg)\r\n</div>\r\n\r\n\r\n## Overview\r\n\r\n**Extract content from documents easily with Python.**\r\n\r\n- Extract from PDFs and other formats\r\n- Process one or many files\r\n- Choose what to extract (tables, text, etc.)\r\n- Export results to JSON, CSV, Excel\r\n- Simple and flexible API\r\n\r\n## \ud83d\udce6 Installation\r\n\r\n```bash\r\npip install docviz-python\r\n```\r\n\r\n## Quick Start\r\n\r\n### Basic Usage\r\n\r\n```python\r\nimport asyncio\r\nimport docviz\r\n\r\nasync def main():\r\n    # Create a document instance\r\n    document = docviz.Document(\"path/to/your/document.pdf\")\r\n    \r\n    # Extract all content\r\n    extractions = await document.extract_content()\r\n    \r\n    # Save results\r\n    extractions.save(\"results\", save_format=docviz.SaveFormat.JSON)\r\n\r\nasyncio.run(main())\r\n```\r\n\r\n### Synchronous Usage\r\n\r\n```python\r\nimport docviz\r\n\r\ndocument = docviz.Document(\"path/to/your/document.pdf\")\r\nextractions = document.extract_content_sync()\r\nextractions.save(\"results.json\", save_format=docviz.SaveFormat.JSON)\r\n```\r\n\r\n## Code Examples\r\n\r\n### Batch Processing\r\n\r\n```python\r\nimport docviz\r\nfrom pathlib import Path\r\n\r\n# Process all PDF files in a directory\r\npdf_directory = Path(\"data/papers/\")\r\noutput_dir = Path(\"output/\")\r\noutput_dir.mkdir(exist_ok=True)\r\n\r\npdfs = pdf_directory.glob(\"*.pdf\")\r\ndocuments = [docviz.Document(str(pdf)) for pdf in pdfs]\r\nextractions = docviz.batch_extract(documents)\r\n\r\nfor ext in extractions:\r\n    ext.save(output_dir, save_format=[docviz.SaveFormat.JSON, docviz.SaveFormat.CSV])\r\n```\r\n\r\n### Selective Extraction\r\n\r\n```python\r\nimport docviz\r\n\r\ndocument = docviz.Document(\"path/to/document.pdf\")\r\n\r\n# Extract only specific types of content\r\nextractions = document.extract_content(\r\n    includes=[\r\n        docviz.ExtractionType.TABLE,\r\n        docviz.ExtractionType.TEXT,\r\n        docviz.ExtractionType.FIGURE,\r\n        docviz.ExtractionType.EQUATION,\r\n    ]\r\n)\r\n\r\nextractions.save(\"selective_results.json\", save_format=docviz.SaveFormat.JSON)\r\n```\r\n\r\n### Custom Configuration\r\n\r\n```python\r\nimport docviz\r\n\r\n# Configure extraction settings\r\nconfig = docviz.ExtractionConfig(\r\n    extraction_type=docviz.ExtractionType.ALL,\r\n    extraction_config=docviz.ExtractionConfig(\r\n        extraction_type=docviz.ExtractionType.ALL,\r\n    ),\r\n)\r\n\r\ndocument = docviz.Document(\"path/to/document.pdf\", config=config)\r\nextractions = document.extract_content()\r\nextractions.save(\"configured_results.json\", save_format=docviz.SaveFormat.JSON)\r\n```\r\n\r\n### Streaming Processing\r\n\r\n```python\r\nimport docviz\r\n\r\ndocument = docviz.Document(\"path/to/large_document.pdf\")\r\n\r\n# Process document in chunks to save memory\r\nfor chunk in document.extract_streaming(chunk_size=10):\r\n    # Process each chunk (10 pages at a time)\r\n    chunk.save(f\"chunk_{chunk.page_range}.json\", save_format=docviz.SaveFormat.JSON)\r\n```\r\n\r\n### Progress Tracking\r\n\r\n```python\r\nimport docviz\r\nfrom tqdm import tqdm\r\n\r\ndocument = docviz.Document(\"path/to/document.pdf\")\r\n\r\n# Extract with progress bar\r\nwith tqdm(total=document.page_count, desc=\"Extracting content\") as pbar:\r\n    extractions = document.extract_content(progress_callback=pbar.update)\r\n\r\nextractions.save(\"progress_results.json\", save_format=docviz.SaveFormat.JSON)\r\n```\r\n\r\n### Data Analysis Integration\r\n\r\n```python\r\nimport docviz\r\nimport pandas as pd\r\n\r\ndocument = docviz.Document(\"path/to/document.pdf\")\r\nextractions = document.extract_content()\r\n\r\n# Convert to pandas DataFrame for analysis\r\ndf = extractions.to_dataframe()\r\n\r\n# Basic analysis\r\nprint(f\"Total tables extracted: {len(df[df['type'] == 'table'])}\")\r\nprint(f\"Total figures extracted: {len(df[df['type'] == 'figure'])}\")\r\n\r\n# Save as Excel with multiple sheets\r\nwith pd.ExcelWriter(\"analysis_results.xlsx\") as writer:\r\n    df.to_excel(writer, sheet_name=\"All_Content\", index=False)\r\n    \r\n    # Separate sheets by content type\r\n    for content_type in df[\"type\"].unique():\r\n        type_df = df[df[\"type\"] == content_type]\r\n        type_df.to_excel(writer, sheet_name=f\"{content_type.capitalize()}\", index=False)\r\n```\r\n\r\n## \ud83d\udd27 API Reference\r\n\r\n### Core Classes\r\n\r\n#### `Document`\r\nMain class for document processing.\r\n\r\n```python\r\ndocument = docviz.Document(\r\n    file_path: str,\r\n    config: Optional[ExtractionConfig] = None\r\n)\r\n```\r\n\r\n#### `ExtractionConfig`\r\nConfiguration for content extraction.\r\n\r\n```python\r\nconfig = docviz.ExtractionConfig(\r\n    extraction_type: ExtractionType = ExtractionType.ALL,\r\n    # Additional configuration options\r\n)\r\n```\r\n\r\n#### `ExtractionType`\r\nEnumeration of extractable content types:\r\n- `TEXT` - Plain text content\r\n- `TABLE` - Tabular data\r\n- `FIGURE` - Images and figures\r\n- `EQUATION` - Mathematical equations\r\n- `ALL` - All content types\r\n\r\n#### `SaveFormat`\r\nSupported output formats:\r\n- `JSON` - JavaScript Object Notation\r\n- `CSV` - Comma-separated values\r\n- `EXCEL` - Microsoft Excel format\r\n\r\n\r\n## \ud83d\udcc4 License\r\n\r\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\r\n\r\n---\r\n\r\n<div align=\"center\">\r\n  <p style=\"background-color:rgb(22, 22, 22); padding: 10px; border-radius: 10px;\">Made with \u2764\ufe0f by <a href=\"https://github.com/fresh-milkshake\">fresh-milkshake</a></p>\r\n</div>\r\n\r\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2025 fresh-milkshake  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "A Python library for extracting and analyzing content from any documents, supporting batch and selective extraction, custom configuration, and multiple output formats.",
    "version": "0.2.0",
    "project_urls": null,
    "split_keywords": [
        "pdf",
        " document analysis",
        " extraction",
        " scientific papers",
        " batch processing"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "53af123b8ef87be8a6cbf7ba7d7b69e4a7f545bfe2545f6400ae053171bdd689",
                "md5": "df28307144f4047ac8d99aeb428e5967",
                "sha256": "e961dba8539575fe69cd84618367725c3608aae4bcb1a3446a47877f843b6940"
            },
            "downloads": -1,
            "filename": "docviz_python-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "df28307144f4047ac8d99aeb428e5967",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 36153,
            "upload_time": "2025-08-15T14:16:58",
            "upload_time_iso_8601": "2025-08-15T14:16:58.689565Z",
            "url": "https://files.pythonhosted.org/packages/53/af/123b8ef87be8a6cbf7ba7d7b69e4a7f545bfe2545f6400ae053171bdd689/docviz_python-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "3118717878be9d107c2fea3cfde69269c085fdd2a8cf5b0e31a22343f5549c69",
                "md5": "4715bed1e2e6de9fa7abf2e5bc07b177",
                "sha256": "ab694ce3783440f423de1fbec87a99aa3c1289d2ec2a1b3f3a52571b50282a25"
            },
            "downloads": -1,
            "filename": "docviz_python-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "4715bed1e2e6de9fa7abf2e5bc07b177",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 29652,
            "upload_time": "2025-08-15T14:16:59",
            "upload_time_iso_8601": "2025-08-15T14:16:59.836186Z",
            "url": "https://files.pythonhosted.org/packages/31/18/717878be9d107c2fea3cfde69269c085fdd2a8cf5b0e31a22343f5549c69/docviz_python-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-15 14:16:59",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "docviz-python"
}
        
Elapsed time: 1.39796s