The pad command is used to pad CSV data records out to some fixed size. It is useful when your CSV source consists of rows containing variable numbers of fields but the application that consumes the CSV requires a fixed number of fields.

See also: order, truncate, put

Flag

Req'd?

Description

-n num

Yes

Specifies the number of fields to pad to. If a row contains more than this number of fields, they will be untouched - the pad command never removes rows.

-p values

No

By default, padding is performed using the empty string. You can also specify values to pad with using the -p flag. For example:

-p NULL

will pad with the string "NULL" while

-p NULL,0

will pad the first missing field with "NULL" and the remainder with "0".



The following example pads the sales_quarter.csv file with NULLS:

csvfix pad -n 5 -p NULL data/sales_quarter.csv

which produces:

"2000","200","550","NULL","NULL"
"2001","178","200","233","140"
"2002","55","104","119","NULL"
"2003","77","NULL","NULL","NULL"


Created with the Personal Edition of HelpNDoc: Free CHM Help documentation generator