write_fixed

Commands ››
Parent Previous Next

The write_fixed command produces fixed-format output. This can be useful if you need to convert CSV files into something acceptable to other (probably legacy) systems. To produce the output, you specify the CSV fields you want it to contain and their widths.

See also: read_fixed, split_fixed

Flag

Req'd?

Description

-f fields

Yes

Specifies a comma-separated list of fields that you want to output. Each field consists of a field index in the output, a colon separator and a width to pad or truncate the field to.

-ru

No

Outputs an 80-column ruler before outputting any data. This can be useful for checking that you have your data formatted correctly.



The following example outputs the names.csv file in fixed format with 16 characters for the surname, 16 for the forename and one for the sex:

csvfix write_fixed -f 1:16,2:16,3:1 data/names.csv

which produces:

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

Created with the Personal Edition of HelpNDoc: Free help authoring tool