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-1.1.tar.gz (2.4 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: swiftscribe_templater-1.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-1.1.tar.gz
Algorithm Hash digest
SHA256 7c67723d582f23e3cb21154c6aaeb7c3b957d76c8b3047be74b3b33d8cd0809c
MD5 cd68e804fbc3a03fe9f9158add01f2d0
BLAKE2b-256 118bbf735583211c0647be546107f7849906708b928ccd688ff08d25c21d1cbd

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