Skip to main content

rename

The rename command renames columns in a CSV file.

Syntax

qsv rename <old_column_name>,<new_column_name> [<input_file>] [<output_file>]

Description

The rename command renames columns in a CSV file. It reads from stdin if no input file is specified and writes to stdout if no output file is given.

Options

  • None specific to rename

Exit Codes

  • 0: Rename successful
  • Non-zero: An error occurred

Examples

Basic Usage

Rename the 'Country' column to 'Nation':

qsv rename Country,Nation olympics2024.csv | qsv select Nation,Gold,Total | qsv table

Output:

Nation         Gold  Total
United States 39 113
China 38 88
Japan 27 58
Great Britain 22 65
ROC 20 71

Common Use Cases

  • Standardizing column names across datasets
  • Correcting typos or inconsistencies in column names
  • Making column names more descriptive or meaningful

Tips

  • Use rename in combination with other qsv commands for more complex data processing
  • Verify the column names after renaming by sampling the output

See Also

  • select - for selecting specific columns
  • table - for displaying data in a tabular format