csvstack1
Csvstack documentation
Overview
Stack up the rows from multiple CSV files, optionally adding a grouping value to each row:
usage: csvstack [-h] [-d DELIMITER] [-t] [-q QUOTECHAR] [-u {0,1,2,3}] [-b][-p ESCAPECHAR] [-z FIELD_SIZE_LIMIT] [-e ENCODING] [-S] [-H][-K SKIP_LINES] [-v] [-l] [--zero] [-V] [-g GROUPS][-n GROUP_NAME] [--filenames][FILE [FILE ...]]Stack up the rows from multiple CSV files, optionally adding a grouping value.positional arguments:FILE The CSV file(s) to operate on. If omitted, will acceptinput as piped data via STDIN.optional arguments:-h, --help show this help message and exit-g GROUPS, --groups GROUPSA comma-separated list of values to add as "groupingfactors", one per CSV being stacked. These are addedto the output as a new column. You may specify a namefor the new column using the -n flag.-n GROUP_NAME, --group-name GROUP_NAMEA name for the grouping column, e.g. "year". Only usedwhen also specifying -g.--filenames Use the filename of each input file as its groupingvalue. When specified, -g will be ignored.
See also: Arguments common to all tools.
WARNING:
If you redirect output to an input file like csvstack file.csv > file.csv, the file will grow indefinitely.
Examples
Join a set of files for different years:
csvstack -g 2009,2010 examples/realdata/FY09_EDU_Recipients_by_State.csv examples/realdata/Datagov_FY10_EDU_recp_by_State.csv
Add a single column to the left of a CSV:
csvstack -n NEWCOL -g "" examples/dummy.csv
Releases
4 releases since Debian 11 (Bullseye); the text changed 3 times.
--delimiter until Debian 12 (Bookworm);
--encoding until Debian 12 (Bookworm);
--escapechar until Debian 12 (Bookworm);
--filenames until Debian 12 (Bookworm);
--group-name until Debian 12 (Bookworm);
--groups until Debian 12 (Bookworm);
--help until Debian 12 (Bookworm);
--linenumbers until Debian 12 (Bookworm);
--maxfieldsize until Debian 12 (Bookworm);
--no-doublequote until Debian 12 (Bookworm);
--no-header-row until Debian 12 (Bookworm);
--quotechar until Debian 12 (Bookworm);
--quoting until Debian 12 (Bookworm);
--skip-lines until Debian 12 (Bookworm);
--skipinitialspace until Debian 12 (Bookworm);
--tabs until Debian 12 (Bookworm);
--verbose until Debian 12 (Bookworm);
--version until Debian 12 (Bookworm);
--zero until Debian 12 (Bookworm);
-H until Debian 12 (Bookworm);
-K until Debian 12 (Bookworm);
-S until Debian 12 (Bookworm);
-V until Debian 12 (Bookworm);
-b until Debian 12 (Bookworm);
-d until Debian 12 (Bookworm);
-e until Debian 12 (Bookworm);
-g until Debian 12 (Bookworm);
-h until Debian 12 (Bookworm);
-l until Debian 12 (Bookworm);
-n until Debian 12 (Bookworm);
-p until Debian 12 (Bookworm);
-q until Debian 12 (Bookworm);
-t until Debian 12 (Bookworm);
-u until Debian 12 (Bookworm);
-v until Debian 12 (Bookworm);
-z until Debian 12 (Bookworm).