datamash -t, --header-in -g 3 collapse 1 < data.csv

Category: Data Science & Analysis

datamash -t, --header-in -g 3 collapse 1 < data.csv

Collapse column 1 values into one comma list per group

The collapse operation joins every value of column 1 inside a group into a single comma-separated list. Grouped by column 3, each output row pairs one group label with all its associated values from column 1. This is handy for building lookup tables or summarizing many-to-one relations. The separator between collapsed values can be changed with the --collapse-delimiter flag.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.