Skip to content

Latest commit

 

History

History
80 lines (55 loc) · 2.95 KB

File metadata and controls

80 lines (55 loc) · 2.95 KB

fixedwidth

Convert fixed-width text (fields at fixed byte-column positions, no delimiters) to CSV.

Table of Contents | Source: src/cmd/fixedwidth.rs

Description | Examples | Usage | Fixedwidth Options | Common Options

Description

Converts fixed-width text (fields at fixed byte-column positions, no delimiters) to CSV.

By default, this expects the input's first line to be a comment enumerating the 1-based starting byte position of each column, comma-separated and prefixed with "#" - the same format qsv table --align leftfwf produces (e.g. "#1,10,15"). Every subsequent line is a data record; each field runs from its starting position up to (but not including) the next column's starting position, or to the end of the line for the last column. Trailing whitespace in each field is trimmed.

If the input doesn't have such a header comment - e.g. it comes from an external system - specify the column positions explicitly with --positions, or column widths with --widths.

Examples

Convert output of qsv table --align leftfwf back to CSV:

qsv table --align leftfwf data.csv | qsv fixedwidth > roundtrip.csv

Convert a file with explicit 1-based column start positions:

qsv fixedwidth --positions 1,10,15 mainframe_extract.txt

Convert a file with explicit column widths instead of positions:

qsv fixedwidth --widths 9,5,20 mainframe_extract.txt

See also https://github.com/dathere/qsv/wiki/Transform-and-Reshape#fixedwidth

Usage

qsv fixedwidth [options] [<input>]
qsv fixedwidth --help

Fixedwidth Options

     Option      Type Description Default
 ‑‑positions  string Comma-separated, 1-based starting byte position of each column (e.g. "1,10,15"). Overrides any "#..." header comment in the input.
 ‑‑widths  string Comma-separated width, in bytes, of each column (e.g. "9,5,20"). An alternative to --positions; the two are mutually exclusive.

Common Options

     Option      Type Description Default
 ‑h,
‑‑help 
flag Display this message
 ‑o,
‑‑output 
string Write output to instead of stdout.

Source: src/cmd/fixedwidth.rs | Table of Contents | README