← 返回命令列表

Linux command

csvtool 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Extract specific columns

csvtool col [1,3,5] [data.csv]

Extract rows by range

csvtool head [10] [data.csv]

Transpose CSV

csvtool transpose [data.csv]

Join columns

csvtool paste [file1.csv] [file2.csv]

Replace values

csvtool replace [column] [old] [new] [data.csv]

Custom delimiter

csvtool -t "[;]" col [1,2] [data.csv]

说明

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.

参数

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.

FAQ

What is the csvtool command used for?

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.

How do I run a basic csvtool example?

Run `csvtool col [1,3,5] [data.csv]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does col _COLUMNS_ do in csvtool?

Extract specified columns (1-indexed, comma-separated).