Skip to content

A python tool to generically apply the contents of a CSV file to a Jinja template.

License

Notifications You must be signed in to change notification settings

tedkotz/csvjinja

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

csvjinja

A python tool to generically apply the contents of a CSV file to a Jinja2 template.

The data from the CSV file is read in and applied to the template as a 2 dimensional array called sheet.

The sample tempates include an exmaple to generate a markdown table and to take contact information and build an html document for printing address labels .

Usage

csvjinja.py [-h] [-d DELIMITER] [-q QUOTE] template_file [csv_file] [output_file]

positional arguments:

template_file
The file containing the Jinja2 template
csv_file
The input data file in csv format. Defaults to standard input
output_file
The output data file to write. Defaults to standard output

optional arguments:

-h, --help
Show this help message and exit
-d DELIMITER, --delimiter DELIMITER
Set character used for field delimiter. Defaults to autodetect
-q QUOTE, --quote QUOTE
Set character used for quoting fields. Defaults to autodetect

Features

  • CSV file available in template as sheet
  • Command line arguments available in template as args

Requirements

  • Python
  • python-jinja2

Todo

  • Store max column size for use in template formatting
  • Support for arbitrary command line parameter passing into template
  • Cut down the number of passes through the CSV file
    • Could a more functional approach to the design do the job?
    • Maybe grab more state info on first pass?

About

A python tool to generically apply the contents of a CSV file to a Jinja template.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published