fixlengths

May 31, 2026 · View on GitHub

Force a CSV to have same-length records by either padding or truncating them.

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

Description | Usage | Fixlengths Options | Common Options

Description

Transforms CSV data so that all records have the same length. The length is the length of the longest record in the data (not counting trailing empty fields, but at least 1). Records with smaller lengths are padded with empty fields.

This requires two complete scans of the CSV data: one for determining the record size and one for the actual transform. Because of this, the input given must be a file and not stdin.

Alternatively, if --length is set, then all records are forced to that length. This requires a single pass and can be done with stdin.

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

Usage

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

Fixlengths Options

     Option     TypeDescriptionDefault
 ‑l,
‑‑length 
integerForcefully set the length of each record. If a record is not the size given, then it is truncated or expanded as appropriate.
 ‑r,
‑‑remove‑empty 
flagRemove empty columns.
 ‑i,
‑‑insert 
integerIf empty fields need to be inserted, insert them at . If is zero, then it is inserted at the end of each record. If is negative, it is inserted from the END of each record going backwards. If is positive, it is inserted from the BEGINNING of each record going forward.0
 ‑‑quote stringThe quote character to use."
 ‑‑escape stringThe escape character to use. When not specified, quotes are escaped by doubling them.

Common Options

     Option     TypeDescriptionDefault
 ‑h,
‑‑help 
flagDisplay this message
 ‑o,
‑‑output 
stringWrite output to instead of stdout.
 ‑d,
‑‑delimiter 
stringThe field delimiter for reading CSV data. Must be a single character. (default: ,)
 ‑q,
‑‑quiet 
flagDon't print removed column information.

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