fill

May 31, 2026 · View on GitHub

Fill empty values.

Table of Contents | Source: src/cmd/fill.rs | 👆

Description | Usage | Fill Options | Common Options

Description ↩

Fill empty fields in selected columns of a CSV.

This command fills empty fields in the selected column using the last seen non-empty field in the CSV. This is useful to forward-fill values which may only be included the first time they are encountered.

The option --default <value> fills all empty values in the selected columns with the provided default value. When --default is set, it takes precedence over forward-fill and --first, which become no-ops.

The option --first fills empty values using the first seen non-empty value in that column, instead of the most recent non-empty value in that column.

The option --backfill fills empty values at the start of the CSV with the first valid value in that column. This requires buffering rows with empty values in the target column which appear before the first valid value.

The option --groupby groups the rows by the specified columns before filling in the empty values. Using this option, empty values are only filled with values which belong to the same group of rows, as determined by the columns selected in the --groupby option.

When both --groupby and --backfill are specified, and the CSV is not sorted by the --groupby columns, rows may be re-ordered during output due to the buffering of rows collected before the first valid value.

For examples, see https://github.com/dathere/qsv/blob/master/tests/test_fill.rs. See also https://github.com/dathere/qsv/wiki/Transform-and-Reshape#fill

Usage ↩

qsv fill [options] [--] <selection> [<input>]
qsv fill --help

Fill Options ↩

     Option     TypeDescriptionDefault
 ‑g,
‑‑groupby 
stringGroup by specified columns.
 ‑f,
‑‑first 
flagFill using the first valid value of a column, instead of the latest.
 ‑b,
‑‑backfill 
flagFill initial empty values with the first valid value.
 ‑v,
‑‑default 
stringFill using this default value.

Common Options ↩

     Option     TypeDescriptionDefault
 ‑h,
‑‑help 
flagDisplay this message
 ‑o,
‑‑output 
stringWrite output to instead of stdout.
 ‑n,
‑‑no‑headers 
flagWhen set, the first row will not be interpreted as headers. (i.e., They are not searched, analyzed, sliced, etc.)
 ‑d,
‑‑delimiter 
stringThe field delimiter for reading CSV data. Must be a single character. (default: ,)

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