Skip to content

Instantly share code, notes, and snippets.

@Drezil
Created March 15, 2019 09:21
Show Gist options
  • Save Drezil/9c9853d8bbad184619d62ff81dddb74f to your computer and use it in GitHub Desktop.
Save Drezil/9c9853d8bbad184619d62ff81dddb74f to your computer and use it in GitHub Desktop.
Groupby for key,value-csv-files
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