Last active
July 20, 2024 23:35
-
-
Save codingtony/b667b9b1feed1cb3af6e221acd7085b0 to your computer and use it in GitHub Desktop.
Get school list from fraser institute as CSV
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
#!/bin/bash | |
wget https://www.compareschoolrankings.org/api/v1/schools.json -O school.json | |
jq '.data[] | { sid:.sid, title:.title, province:.province, type:.schoolType, rank:.schoolInfoData."Rank This Yr", city:.schoolInfoData.SchoolCity, pubOrPriv:.schoolInfoData.IND_or_PUB,lang:.schoolInfoData.SchoolLanguage,admin:.schoolInfoData.AdminBodyName } ' school.json | jq -rn -L. 'include "json2csv"; [inputs]|json2csv' > school.csv |
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
def json2headers: | |
def isscalar: type | . != "array" and . != "object"; | |
def isflat: all(.[]; isscalar); | |
paths as $p | |
| getpath($p) | |
| if type == "array" and isflat then $p | |
elif isscalar and (($p[-1]|type) == "string") then $p | |
else empty end ; | |
def json2array($header): | |
def value($p): | |
try getpath($p) catch null | |
| if type == "object" then null else . end; | |
[$header[] as $p | value($p)]; | |
def json2csv: | |
( [.[] | json2headers] | unique) as $h | |
| ([$h[]|join("_") ], | |
(.[] | |
| json2array($h) | |
| map( if type == "array" then map(tostring)|join("|") else tostring end))) | |
| @csv ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes it seems to be encrypted. The key seems to be in the javascript