Skip to main content

module to ease the docx report generation using templates and importing features

Project description

pyDocxReport

Ease the docx report generation using templates and importing features

DataBridge

DataBridge class manages resources and match them with keyword set in a template docx file. All keywords in the template so referenced ar replaced by the appropriate content. An example of use with a yml file as a matchs dictionary is given below:

bridge = DataBridge(
    'path/to/template.docx',
    {'text1':'this is my replacement text', 'text2':'and another one'},
    {'table1': df1},
    {'imageset1': ['path/to/image1.jpg', 'path/to/image1.jpg'], 'imageset2':['path/to/image2.tiff']}
    )

bridge.match(matchs)
bridge.save('path/to/output.docx')

where matchs is defined as a yml file like below:

    _keyword1_:
        replacewith: string
        parameters:
            replacement: text1
    _myimage1set_:
        replacewith: images
        parameters:
            replacement: imageset1
            width: 120
    _logo_:
        replacewith: images
        parameters:
            replacement: imageset2
            height: 10
    _keyword2_:
        replacewith: table
        parameters:
            replacement: table1
            header: false               # if header is true, the column names of the DataFrame are used as header. Otherwiser no header. Default is no header
    _text2_:
        replacewith: string
        parameters:
            replacement: text2

See tests to see this example implemented.

DocxTemplate

The DocxTemplate class makes use of python-docx to modify a word document. Use DataBridge for a standard operation and use DocxTemplate when you need to tune some replacements.

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

pyDocxReport-0.0.1.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

pyDocxReport-0.0.1-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file pyDocxReport-0.0.1.tar.gz.

File metadata

  • Download URL: pyDocxReport-0.0.1.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.6.11

File hashes

Hashes for pyDocxReport-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f917497a028cc4c9d6b4392f9480d6ad77c2ce25a406da695c5da24c795d6350
MD5 55491b7a0073ab03d9e139e43d20870e
BLAKE2b-256 6b8b13440635c275e20c65cd7302941a0fcbe75ddaabdfe50d8c0d8d5d601bb3

See more details on using hashes here.

File details

Details for the file pyDocxReport-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: pyDocxReport-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.6.11

File hashes

Hashes for pyDocxReport-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c582fadaa2ef25015dda457f7b62da38b365e88775642eab98e46ceeda74b46f
MD5 dbc12a5d719365403f71a86a4cc0f68d
BLAKE2b-256 2c4fa32467e8a0d465a45be4d7d7c08a785e926f09397385848f63f53e16c242

See more details on using hashes here.

Supported by

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