Skip to content

Instantly share code, notes, and snippets.

@tibotiber
Last active August 29, 2015 14:05
Show Gist options
  • Save tibotiber/ffca33cb7261e463928d to your computer and use it in GitHub Desktop.
Save tibotiber/ffca33cb7261e463928d to your computer and use it in GitHub Desktop.
log2csv
#!/bin/sh
echo 'date,fsr1,fsr2,fsr3,fsr4,fsr5,fsr6,fsr7,fsr8,event' > 2014080${1}.csv
grep 'Preparing to post message: {' zigbee-gw2014080${1}.log | sed 's/[^{]*\({.*}\), to.*/\1/' | sed "s/'/\"/g" | sed 's/u"/"/g' | jq '"\(.date),\(.sample.R1),\(.sample.R2),\(.sample.R3),\(.sample.R4),\(\
.sample.R5),\(.sample.R6),\(.sample.R7),\(.sample.R8),\(.value)"' | sed 's/null//g' | sed 's/"//g' >> 2014080${1}.csv
#!/bin/sh
./log2csv.sh 5
./log2csv.sh 6
./log2csv.sh 7
@tibotiber
Copy link
Author

Uses jq for json parsing in shell. So install it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment