The template command passes its output through a textual template specified in a template file. Place holders in the template are replaced by values from the CSV data.
Template files look like this:
This is the first value {1}
And this {2} is the second
where {1} and {2} are place holders that will be replaced by the values of fields 1 and 2 in the command's input. If you need to output literal braces, escape them with backslashes.
It might seem that templates can do most things that some other CSVfix commands do. This is true to a certain extent, but templates have a number of drawbacks:
● You have to write and maintain the template file.
● Templates don't do special character quoting.
● Templates don't handle variable numbers of fields well.
Note that the output of a template command is not CSV, unless you explicitly make it so in the template specification.
See also: printf
Flag |
Req'd? |
Description |
-tf tfile |
Yes |
Name of template file. |
The following example lists the names.csv file using a template. The template file (names.tpl) looks like this:
Name: {1} {2}
Sex: {3}
The command line:
csvfix.exe template -tf data/names.tpl data/names.csv
produces:
Name: Charles Dickens
Sex: M
Name: Jane Austen
Sex: F
Name: Herman Melville
Sex: M
Name: Flann O'Brien
Sex: M
Name: George Elliot
Sex: F
Name: Virginia Woolf
Sex: F
Name: Oscar Wilde
Sex: M
Created with the Personal Edition of HelpNDoc: Full featured Help generator