Skip to main content

Insert pandas DataFrames as tables into Microsoft Word documents

Project description

docdocgo

Insert pandas DataFrames as tables into Microsoft Word documents.

Features

  • Simple API: Just call docdocgo(df, "document.docx") to update Word documents
  • Marker Replacement: Use markers like {{QUARTERLY_NUMBERS}} in your Word templates
  • Professional Styling: Tables with dark blue headers and alternating row colors
  • Type Support: Handles all pandas data types including NaN values
  • Performance Optimized: Efficient table creation for large DataFrames

Installation

uv add docdocgo

Or with pip:

pip install docdocgo

Quick Start

import pandas as pd
from docx import Document
import docdocgo

data = pd.DataFrame({
    "Quarter": ["Q1", "Q2", "Q3", "Q4"],
    "Revenue": [120000, 135000, 142000, 158000],
    "Profit": [25000, 32000, 28000, 41000],
})

doc = Document()
doc.add_heading("Quarterly Report", 0)
doc.add_paragraph("Here are the quarterly results:")
doc.add_paragraph("{{QUARTERLY_DATA}}")
doc.add_paragraph("Thank you for reviewing this report.")
doc.save("template.docx")

docdocgo.insert_table(data, "template.docx", "{{QUARTERLY_DATA}}", "result.docx")

This transforms your template document into a final report:

📄 template.docx → 📊 result.docx

From template with marker to professional report with formatted table

API Reference

docdocgo(df, path, marker=None, output_path=None)

Convenience function to insert DataFrame into Word document.

Parameters:

  • df (pandas.DataFrame): DataFrame to insert
  • path (str | Path): Path to Word document
  • marker (str, optional): Marker to replace. If None, creates new document
  • output_path (str | Path, optional): Output path. If None, overwrites input file

create_document_with_table(df, output_path)

Create a new Word document with a DataFrame table.

Parameters:

  • df (pandas.DataFrame): DataFrame to insert
  • output_path (str | Path): Path for the new document

insert_table(df, docx_path, marker, output_path=None)

Replace a marker in an existing Word document with a DataFrame table.

Parameters:

  • df (pandas.DataFrame): DataFrame to insert
  • docx_path (str | Path): Path to existing Word document
  • marker (str): Marker string to replace
  • output_path (str | Path, optional): Output path. If None, overwrites input document

Development

Uses just.

# Clone and setup
git clone <repository>
cd docdocgo
uv sync

# Run tests and examples
just test

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docdocgo-0.1.0.tar.gz (216.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

docdocgo-0.1.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file docdocgo-0.1.0.tar.gz.

File metadata

  • Download URL: docdocgo-0.1.0.tar.gz
  • Upload date:
  • Size: 216.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.5

File hashes

Hashes for docdocgo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9fec77454ce7c8d3df3967b69730d0b29bce96fa6df8ca0d2ef8adfc06ad222a
MD5 9af141d920c2ca4a9b28d7c0808c8e91
BLAKE2b-256 7667c9c44e79f0cca3aeac74dc7e8d45c72976781f2da474b8fa242c42289ef6

See more details on using hashes here.

File details

Details for the file docdocgo-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: docdocgo-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.5

File hashes

Hashes for docdocgo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 70843a42bf629e897716f51b479a5724edf0396d77a8d72124e6c1bf53fbae50
MD5 88e8e5b988011245fa7d85fd7d2253b3
BLAKE2b-256 406f40fc54d9edef9185aab8054b25b0d4653c09aba2fb592f99c5e27492f579

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page