rename

May 31, 2026 · View on GitHub

Rename the columns of a CSV efficiently.

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

Description | Examples | Usage | Arguments | Common Options

Description

Rename the columns of a CSV efficiently. It has two modes of operation:

Positional mode (default):
The new column names are given as a comma-separated list of names. The number of column names given MUST match the number of columns in the CSV unless "_all_generic" is used.

Pairwise mode:
The new column names are given as a comma-separated list of pairs of old and new column names. The format is "old1,new1,old2,new2,...".

Examples

Change the column names of a CSV with three columns:

qsv rename id,name,title

Rename only specific columns using pairs:

qsv rename --pairwise oldname,newname,oldcol,newcol

Replace the column names with generic ones (_col_N):

qsv rename _all_generic

Add generic column names to a CSV with no headers:

qsv rename _all_generic --no-headers

Use column names that contains commas and conflict with the separator:

qsv rename '"Date - Opening","Date - Actual Closing"'

For more examples, see tests.

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

Usage

qsv rename [options] [--] <headers> [<input>]
qsv rename --help

Arguments

 Argument  Description
 <headers> The new headers to use for the CSV. Separate multiple headers with a comma. If "_all_generic" is given, the headers will be renamed to generic column names, where the column name uses the format "_col_N" where N is the 1-based column index. Alternatively, specify pairs of old,new column names to rename only specific columns.

Common Options

     Option     TypeDescriptionDefault
 ‑h,
‑‑help 
flagDisplay this message
 ‑o,
‑‑output 
stringWrite output to instead of stdout.
 ‑n,
‑‑no‑headers 
flagWhen set, the header will be inserted on top.
 ‑d,
‑‑delimiter 
stringThe field delimiter for reading CSV data. Must be a single character. (default: ,)

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