Skip to content

Instantly share code, notes, and snippets.

@ejoubaud
Last active December 17, 2015 02:48
Show Gist options
  • Save ejoubaud/5538267 to your computer and use it in GitHub Desktop.
Save ejoubaud/5538267 to your computer and use it in GitHub Desktop.
Parses Excel spreadsheets from the review team for big category changes by item ID
# Parse category migrations by ID from Excel files
#
# Just:
# * paste from the spreadsheet into Sublime
# * paste this line in Shell Turtlestein (plugin) invite
# * replace $4 and $1 by $<category_column_index> and $<id_column_index> (1-based index)
#
# Can be easily adapted for VIM, it's just awk
| awk -F "\t" '{ cat = $4; id = $1; ids_per_line = 5; sep = (count[cat]==0) ? "" : (count[cat] % ids_per_line == 0) ? ",\n " : ", " ; by_cat[cat] = by_cat[cat] sep id; count[cat] = count[cat] + 1 } END { for (cat in by_cat) { print "\"" cat "\" => [\n " by_cat[cat] "\n]," } }' >
<<EXAMPLE
4474497 approved Baby Clothes Mock-Up apparel/miscellaneous
471433 soft_disabled T-Shirt Template Mockup apparel/t-shirts
4407524 approved Photorealistic Clothes Brand Mock-Ups apparel/miscellaneous
becomes
"apparel/miscellaneous" => [
4474497, 4407524
],
"apparel/t-shirts" => [
471433
],
EXAMPLE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment