Skip to main content

Generate documents based on a template and populate the tokens within the document.

Project description

SwiftScribe Templater

SwiftScribe Templater is a Python package that provides functionality for tokenizing Word documents and replacing tokens.

Installation

You can install SwiftScribe Templater using pip:

pip install swiftscribe-templater

Usage

Import the library

from swift_templater import tokenize_word_document, replace_tokens

Specify the template, define the variables and lastly define the output document path.

# Tokenize Word Document
doc_path = "template.docx"
doc_tokens = tokenize_word_document(doc_path)

# Replace Tokens
replacement_dict = {"{title}": "John Doe", 
                    "{date}": "2024-01-24"}

modified_doc = replace_tokens(doc_path, replacement_dict)

# Save the modified document
modified_doc.save("output.docx")

Remember to add the tokens inside your word template. For example:

{title}
{date}

Dependencies

  • nltk
  • python-docx

License

This project is licensed under the MIT License.

Acknowledgments

Contributing

Contributions are welcome! Please feel free to open an issue or submit a pull request.

Authors

Nathan Budhu

Contact

For any questions or feedback, please contact nathanbudhu@gmail.com.

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

swiftscribe_templater-1.2.tar.gz (2.4 kB view details)

Uploaded Source

File details

Details for the file swiftscribe_templater-1.2.tar.gz.

File metadata

  • Download URL: swiftscribe_templater-1.2.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for swiftscribe_templater-1.2.tar.gz
Algorithm Hash digest
SHA256 924964e518795d07e3399aba8067202fcf229392086b35d97c7854bc83c6c788
MD5 82293ff3ef0d8ef26fec72c5e606fe81
BLAKE2b-256 af277dcb93eca803bb9dea461cb1b3b1a629c82a755936965cc317ea49e6f759

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