LinuxCommandLibrary

csvtool

Fast CSV manipulation utility

TLDR

Extract specific columns from a CSV

$ csvtool col [1,3,5] [data.csv]
copy
Extract rows by range
$ csvtool head [10] [data.csv]
copy
Transpose CSV (rows become columns)
$ csvtool transpose [data.csv]
copy
Join columns from multiple files
$ csvtool paste [file1.csv] [file2.csv]
copy
Replace values in a column
$ csvtool replace [column] [old] [new] [data.csv]
copy
Custom delimiter input
$ csvtool -t "[;]" col [1,2] [data.csv]
copy

SYNOPSIS

csvtool [options] command [arguments] file

DESCRIPTION

csvtool is a fast CSV manipulation utility written in OCaml. It provides various operations for transforming, filtering, and analyzing CSV data from the command line.
The tool is designed for speed and handles large files efficiently. It supports common operations like column extraction, row filtering, transposition, and file joining. The call command enables running external commands for each row.
csvtool uses a streaming approach where possible, allowing it to process files larger than available memory for many operations. It properly handles CSV quoting and escaping.

PARAMETERS

col COLUMNS

Extract specified columns (1-indexed, comma-separated).
head N
Output first N rows.
drop N
Drop first N rows.
transpose
Transpose rows and columns.
paste
Paste files side by side.
replace COL OLD NEW
Replace values in a column.
join COL
Join files on a column.
call COMMAND
Run command for each row.
-t CHAR
Input delimiter (default: comma).
-u CHAR
Output delimiter.
-o FILE
Output file.

CAVEATS

Column numbers are 1-indexed, not 0-indexed. Some operations require loading the entire file into memory. Quoting rules may differ from other CSV tools. Error messages can be cryptic.

HISTORY

csvtool was developed as a fast, lightweight CSV processor. Written in OCaml for performance, it provides an alternative to heavier tools when simple, fast transformations are needed on CSV data.

SEE ALSO

csvkit(1), cut(1), awk(1), miller(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community