Linux command
csvstack 命令
文件
涉及管道、覆盖或删除,执行前请先确认路径和参数。
常用示例
Stack multiple CSV files
csvstack [file1.csv] [file2.csv] > [combined.csv]
Stack with a grouping column to identify source files
csvstack -g [source1,source2] [file1.csv] [file2.csv]
Name the grouping column
csvstack -g [a,b] -n [source] [file1.csv] [file2.csv]
Stack using filenames as group values automatically
csvstack --filenames [file1.csv] [file2.csv]
Stack files that have no header row
csvstack -H [file1.csv] [file2.csv]
Stack semicolon-delimited files
csvstack -d ";" [file1.csv] [file2.csv]
说明
csvstack concatenates multiple CSV files vertically (row-wise). Part of csvkit, it aligns columns by header name and can add a grouping column to track source files. The tool handles files with different column orders by matching header names, making it robust for combining datasets from different sources.
参数
- -g _names_
- Add grouping column with values.
- -n _name_
- Name for grouping column.
- -H, --no-header-row
- Inputs have no header row.
- --filenames
- Use filenames as group values.
- -d _char_
- Field delimiter.
- -q _char_
- Quote character.
- -e _encoding_
- Input encoding.
FAQ
What is the csvstack command used for?
csvstack concatenates multiple CSV files vertically (row-wise). Part of csvkit, it aligns columns by header name and can add a grouping column to track source files. The tool handles files with different column orders by matching header names, making it robust for combining datasets from different sources.
How do I run a basic csvstack example?
Run `csvstack [file1.csv] [file2.csv] > [combined.csv]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -g _names_ do in csvstack?
Add grouping column with values.