$ go run github.com/adzeitor/csvmagi "This is column foo {foo} and column bar {bar}" < file.csv
Also you can use column numbers using special variables {_1}
, {_2}
, etc in template:
$ go run github.com/adzeitor/csvmagi 'UPDATE some_table SET foo="{_2}" WHERE id="{_1}"'< file.csv
In strict mode you receive errors on undefined columns:
$ go run github.com/adzeitor/csvmagi -strict 'Some of the last columns {_999}' < file.csv
Changing delimiter is also supported:
$ go run github.com/adzeitor/csvmagi -delimiter ';' '{_1} | {_2}' < file.csv
For files without header use -noheader
argument:
$ go run github.com/adzeitor/csvmagi -noheader '{_1} | {_2}' < file.csv
- only support CSV files with headers