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 .
csvjinja.py [-h] [-d DELIMITER] [-q QUOTE] template_file [csv_file] [output_file]
- 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
- -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
- CSV file available in template as
sheet
- Command line arguments available in template as
args
- Python
- python-jinja2
- 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?