Created
June 9, 2021 04:09
-
-
Save saswata-dutta/6637eec34a5d98ac252f3e8a3f9683a4 to your computer and use it in GitHub Desktop.
jq filter group_by and sum
This file contains hidden or 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
cat summary.json | \ | |
jq -r '.weeklyTotalCount[] | to_entries | .[] | select(.value > 0)' | \ | |
jq -s 'group_by(.key) | map({week : .[0].key, count : [.[].value] | add })' |
This file contains hidden or 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
{ | |
"weeklyTotalCount": { | |
"cat1": { | |
"2021-03-02": 0, | |
"2020-11-17": 0, | |
"2020-12-29": 0, | |
"2021-03-23": 0, | |
"2021-04-13": 0, | |
"2020-12-08": 0, | |
"2020-10-06": 0, | |
"2020-10-27": 0, | |
"2020-09-15": 0, | |
"2020-11-24": 0, | |
"2021-05-11": 0, | |
"2021-06-01": 0, | |
"2020-11-03": 0, | |
"2020-12-15": 0, | |
"2020-10-13": 0, | |
"2021-01-19": 0, | |
"2021-02-09": 0, | |
"2021-05-18": 0, | |
"2021-06-08": 0, | |
"2020-09-08": 0, | |
"2021-03-16": 0, | |
"2021-04-06": 0, | |
"2020-09-29": 0, | |
"2021-04-27": 0, | |
"2021-02-23": 0, | |
"2021-01-12": 0, | |
"2021-02-02": 0, | |
"2020-09-22": 0, | |
"2021-03-30": 0, | |
"2021-04-20": 0, | |
"2020-12-01": 0, | |
"2021-05-25": 0, | |
"2021-03-09": 0, | |
"2021-05-04": 0, | |
"2020-11-10": 0, | |
"2020-12-22": 0, | |
"2020-10-20": 0, | |
"2021-01-26": 0, | |
"2021-02-16": 0, | |
"2021-01-05": 0 | |
}, | |
"cat2": { | |
"2021-03-02": 0, | |
"2020-11-17": 0, | |
"2020-12-29": 0, | |
"2021-03-23": 0, | |
"2021-04-13": 0, | |
"2020-12-08": 0, | |
"2020-10-06": 0, | |
"2020-10-27": 0, | |
"2020-09-15": 0, | |
"2020-11-24": 0, | |
"2021-05-11": 0, | |
"2021-06-01": 0, | |
"2020-11-03": 0, | |
"2020-12-15": 0, | |
"2020-10-13": 0, | |
"2021-01-19": 0, | |
"2021-02-09": 0, | |
"2021-05-18": 0, | |
"2021-06-08": 0, | |
"2020-09-08": 0, | |
"2021-03-16": 0, | |
"2021-04-06": 0, | |
"2020-09-29": 0, | |
"2021-04-27": 0, | |
"2021-02-23": 0, | |
"2021-01-12": 0, | |
"2021-02-02": 0, | |
"2020-09-22": 0, | |
"2021-03-30": 0, | |
"2021-04-20": 0, | |
"2020-12-01": 0, | |
"2021-05-25": 0, | |
"2021-03-09": 0, | |
"2021-05-04": 0, | |
"2020-11-10": 0, | |
"2020-12-22": 0, | |
"2020-10-20": 0, | |
"2021-01-26": 0, | |
"2021-02-16": 0, | |
"2021-01-05": 0 | |
}, | |
"cat3": { | |
"2021-03-02": 0, | |
"2020-11-17": 0, | |
"2020-12-29": 0, | |
"2021-03-23": 0, | |
"2021-04-13": 0, | |
"2020-12-08": 0, | |
"2020-10-06": 0, | |
"2020-10-27": 0, | |
"2020-09-15": 0, | |
"2020-11-24": 0, | |
"2021-05-11": 0, | |
"2021-06-01": 0, | |
"2020-11-03": 0, | |
"2020-12-15": 0, | |
"2020-10-13": 0, | |
"2021-01-19": 0, | |
"2021-02-09": 0, | |
"2021-05-18": 0, | |
"2021-06-08": 0, | |
"2020-09-08": 0, | |
"2021-03-16": 0, | |
"2021-04-06": 0, | |
"2020-09-29": 0, | |
"2021-04-27": 0, | |
"2021-02-23": 0, | |
"2021-01-12": 0, | |
"2021-02-02": 0, | |
"2020-09-22": 0, | |
"2021-03-30": 0, | |
"2021-04-20": 0, | |
"2020-12-01": 0, | |
"2021-05-25": 0, | |
"2021-03-09": 0, | |
"2021-05-04": 0, | |
"2020-11-10": 0, | |
"2020-12-22": 0, | |
"2020-10-20": 0, | |
"2021-01-26": 0, | |
"2021-02-16": 0, | |
"2021-01-05": 0 | |
}, | |
"cat4": { | |
"2021-03-02": 0, | |
"2020-11-17": 0, | |
"2020-12-29": 0, | |
"2021-03-23": 0, | |
"2021-04-13": 0, | |
"2020-12-08": 0, | |
"2020-10-06": 0, | |
"2020-10-27": 0, | |
"2020-09-15": 0, | |
"2020-11-24": 0, | |
"2021-05-11": 0, | |
"2021-06-01": 0, | |
"2020-11-03": 0, | |
"2020-12-15": 0, | |
"2020-10-13": 0, | |
"2021-01-19": 0, | |
"2021-02-09": 0, | |
"2021-05-18": 0, | |
"2021-06-08": 0, | |
"2020-09-08": 0, | |
"2021-03-16": 0, | |
"2021-04-06": 0, | |
"2020-09-29": 0, | |
"2021-04-27": 0, | |
"2021-02-23": 0, | |
"2021-01-12": 0, | |
"2021-02-02": 0, | |
"2020-09-22": 0, | |
"2021-03-30": 0, | |
"2021-04-20": 0, | |
"2020-12-01": 0, | |
"2021-05-25": 0, | |
"2021-03-09": 0, | |
"2021-05-04": 0, | |
"2020-11-10": 0, | |
"2020-12-22": 0, | |
"2020-10-20": 0, | |
"2021-01-26": 0, | |
"2021-02-16": 0, | |
"2021-01-05": 0 | |
}, | |
"cat5": { | |
"2021-03-02": 0, | |
"2020-11-17": 0, | |
"2020-12-29": 17, | |
"2021-03-23": 0, | |
"2021-04-13": 0, | |
"2020-12-08": 18, | |
"2020-10-06": 12, | |
"2020-10-27": 18, | |
"2020-09-15": 10, | |
"2020-11-24": 18, | |
"2021-05-11": 1, | |
"2021-06-01": 0, | |
"2020-11-03": 18, | |
"2020-12-15": 18, | |
"2020-10-13": 12, | |
"2021-01-19": 16, | |
"2021-02-09": 0, | |
"2021-05-18": 1, | |
"2021-06-08": 0, | |
"2020-09-08": 11, | |
"2021-03-16": 0, | |
"2021-04-06": 0, | |
"2020-09-29": 12, | |
"2021-04-27": 2, | |
"2021-02-23": 0, | |
"2021-01-12": 16, | |
"2021-02-02": 0, | |
"2020-09-22": 12, | |
"2021-03-30": 0, | |
"2021-04-20": 0, | |
"2020-12-01": 18, | |
"2021-05-25": 0, | |
"2021-03-09": 0, | |
"2021-05-04": 1, | |
"2020-11-10": 18, | |
"2020-12-22": 18, | |
"2020-10-20": 12, | |
"2021-01-26": 16, | |
"2021-02-16": 0, | |
"2021-01-05": 0 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment