Created
March 15, 2019 09:21
-
-
Save Drezil/9c9853d8bbad184619d62ff81dddb74f to your computer and use it in GitHub Desktop.
Groupby for key,value-csv-files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function groupby | |
for o in (cut -d ',' -f 1 $argv[1] | uniq) | |
echo -n "{\"$o\":[" | |
grep "$o" $argv[1] | cut -d ',' -f 2 | sed 's/^\(.*\)$/"\1"/' | tr '\n' ','| sed 's/,$//' | |
echo "]}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment