Linux command
csvcut 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Select specific columns
csvcut -c [1,3,5] [data.csv]
Select columns by name
csvcut -c [name,email] [data.csv]
Exclude columns
csvcut -C [column] [data.csv]
Use different delimiter
csvcut -d ";" -c [1,2] [data.csv]
Select column range
csvcut -c [1-5] [data.csv]
Read from stdin
cat [data.csv] | csvcut -c [name]
说明
csvcut is part of csvkit, a suite of CSV processing utilities. It selects and reorders columns from CSV files, similar to cut but with proper CSV handling including quoted fields. The tool correctly handles CSV edge cases like embedded commas and newlines within quoted fields, making it more reliable than text-based alternatives for structured data.
参数
- -c _columns_
- Columns to select (names or indices).
- -C _columns_
- Columns to exclude.
- -d _char_
- Field delimiter character.
- -t _char_
- Tab delimiter shortcut.
- -q _char_
- Quote character.
- -e _encoding_
- Input file encoding.
- -n
- Display column names and indices.
- -l
- Insert line numbers column.
- --no-header-row
- Input has no header row.
FAQ
What is the csvcut command used for?
csvcut is part of csvkit, a suite of CSV processing utilities. It selects and reorders columns from CSV files, similar to cut but with proper CSV handling including quoted fields. The tool correctly handles CSV edge cases like embedded commas and newlines within quoted fields, making it more reliable than text-based alternatives for structured data.
How do I run a basic csvcut example?
Run `csvcut -c [1,3,5] [data.csv]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -c _columns_ do in csvcut?
Columns to select (names or indices).