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 insertpath(str | Path): Path to Word documentmarker(str, optional): Marker to replace. If None, creates new documentoutput_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 insertoutput_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 insertdocx_path(str | Path): Path to existing Word documentmarker(str): Marker string to replaceoutput_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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fec77454ce7c8d3df3967b69730d0b29bce96fa6df8ca0d2ef8adfc06ad222a
|
|
| MD5 |
9af141d920c2ca4a9b28d7c0808c8e91
|
|
| BLAKE2b-256 |
7667c9c44e79f0cca3aeac74dc7e8d45c72976781f2da474b8fa242c42289ef6
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70843a42bf629e897716f51b479a5724edf0396d77a8d72124e6c1bf53fbae50
|
|
| MD5 |
88e8e5b988011245fa7d85fd7d2253b3
|
|
| BLAKE2b-256 |
406f40fc54d9edef9185aab8054b25b0d4653c09aba2fb592f99c5e27492f579
|