put

Commands ››
Parent Previous Next

The put command allows you to put a literal string or the contents of an environment variable into the CSV output. This can be useful for adding missing values and for tagging output.

See also: pad, eval, timestamp,  sequence

Flag

Req'd?

Description

-p pos

No

Specifies the field position for the value being put, so that a position of "1" puts the value as the first field. If this flag is omitted, the value is placed at the end of the input fields.

-v value

Yes

Specifies the value to put. You must specify this or the -e flag.

-e envvar

Yes

Specifies the name of an environment variable who's value will be put into the output. You must specify this or the -v flag.

The special names @DATETIME and @DATE can be used to put a date stamp (with or without the time part) into the output. The format of the stamp is:

  yyyy-mm-dd hh:mm:sss

For greater control over the stamp format, use the timestamp command.


The special name @COUNT can be used to add the field count of each CSV record to the output.



The following example inserts the string "Name" into the first position in the names.csv file:

csvfix put -p 1 -v "Name" data/names.csv

which produces:

"Name","Charles","Dickens","M"
"Name","Jane","Austen","F"
"Name","Herman","Melville","M"
"Name","Flann","O'Brien","M"
"Name","George","Elliot","F"
"Name","Virginia","Woolf","F"
"Name","Oscar","Wilde","M"


Created with the Personal Edition of HelpNDoc: Easily create EPub books