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 swiftscribe_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("modified_document1.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-0.1.tar.gz (2.4 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: swiftscribe_templater-0.1.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-0.1.tar.gz
Algorithm Hash digest
SHA256 9de583c04a3cca505b7e77d118d2c15d78b073a3019f94424676f8e56dbf2b36
MD5 598544716bfb194b36e3a5095660418e
BLAKE2b-256 c30951fbab31caea02dcf845ab82f434930c52a3926526003e8d7c8267219d0d

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