csv2tmpl

module
v0.0.0-...-489c54b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2020 License: Apache-2.0

README

Simple CSV to template

Go

Use csv2tmpl to take a CSV file and convert to different output using templates. This makes it easy to convert CSV files to e.g. SQL scripts.

csv2tmpl --input cmd/testdata/employees.csv --header-row --template "INSERT INTO employees VALUES ('{{ .employee_num }}', '{{ .name }}', '{{ .department }}');"
INSERT INTO employees VALUES ('001', 'Bill', 'Engineering');
INSERT INTO employees VALUES ('002', 'Jane', 'Management');
Installing

Using csv2tmpl is easy. First, use go get to install the latest version:

go get -u github.com/lagren/csv2tmpl/csv2tmpl
Functions

Use functions to convert values to another format. Supported functions:

  • String manipulation using lower, upper, kebab, snake, camel, prefix, or suffix
  • Calculate hash sum using md5, sha, sha256, or sha512 (hex output)

Example template usage:

  • {{ upper .last_name }} or {{ .last_name | upper }} outputs SMITH
  • {{ prefix "Mr " .last_name }} or {{ .last_name | prefix "Mr " }} outputs Mr Smith
  • {{ suffix "-san" .last_name }} or {{ .last_name | suffix "-san" }} outputs Smith-san

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL