Linux command
csvformat 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Convert CSV to tab-delimited
csvformat -T [input.csv]
Change delimiter
csvformat -D "[;]" [input.csv]
Quote all fields
csvformat -U 1 [input.csv]
Skip first N rows
csvformat -K [1] [input.csv]
Change line terminator
csvformat -M "\r\n" [input.csv]
说明
csvformat is part of csvkit that converts CSV files between different delimited formats. It allows changing field delimiters, quote characters, quoting styles, and line terminators while maintaining proper CSV structure. The tool is useful for converting CSV files to tab-delimited format for Unix tools, standardizing quote handling across files, or reformatting data for systems with specific delimiter requirements. It properly handles CSV quoting rules during conversion. Quoting styles include minimal (quote only when necessary), all fields, non-numeric fields only, and none. The tool can also skip header rows and adjust line endings for cross-platform compatibility.
参数
- -T
- Output tab-delimited.
- -D _delimiter_
- Set output delimiter.
- -U _style_
- Quoting style: 0=minimal, 1=all, 2=non-numeric, 3=none.
- -K _n_
- Skip first n rows.
- -M _char_
- Set output line terminator.
- -d _CHAR_, --delimiter _CHAR_
- Input field delimiter (default: comma).
- -e _ENCODING_, --encoding _ENCODING_
- Input file encoding.
FAQ
What is the csvformat command used for?
csvformat is part of csvkit that converts CSV files between different delimited formats. It allows changing field delimiters, quote characters, quoting styles, and line terminators while maintaining proper CSV structure. The tool is useful for converting CSV files to tab-delimited format for Unix tools, standardizing quote handling across files, or reformatting data for systems with specific delimiter requirements. It properly handles CSV quoting rules during conversion. Quoting styles include minimal (quote only when necessary), all fields, non-numeric fields only, and none. The tool can also skip header rows and adjust line endings for cross-platform compatibility.
How do I run a basic csvformat example?
Run `csvformat -T [input.csv]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -T do in csvformat?
Output tab-delimited.