Created
June 23, 2021 12:37
-
-
Save mfalkvidd/c2c75d23bb648bf539aadf5913f44ade to your computer and use it in GitHub Desktop.
Revisions
-
mfalkvidd created this gist
Jun 23, 2021 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ #!/bin/bash re='^[0-9]+$' if ! [[ "$1" =~ $re ]] ; then echo "Usage: $0 <station_number>" exit fi PAGE=1 OUTPUT="" STATION=$1 JSONFILE="observations_$STATION.json" CSVFILE="observations_$STATION.csv" echo "[" >> "$JSONFILE" while true do OUTPUT=$(curl "https://network.satnogs.org/api/observations/?format=json&ground_station=$STATION&page=$PAGE") if echo "$OUTPUT" | grep -q 'Invalid page'; then break; fi if [[ $PAGE -gt 1 ]]; then echo "," >> "$JSONFILE" fi echo "$OUTPUT" >> "$JSONFILE" PAGE=$((PAGE+1)) done echo "]" >> "$JSONFILE" echo "obs_ID,status,transmitter,satellite" > "$CSVFILE" jq -r '.[][] | "\(.id),\(.status),\(.transmitter_uuid),\(.tle0)"' "$JSONFILE" >> "$CSVFILE" echo "Output is in $CSVFILE"