Last active
June 14, 2022 12:39
-
-
Save TomLous/082733b4f96407e4571ff82b29a26dbe to your computer and use it in GitHub Desktop.
Stream the content of a remote file to a locahost port with custom interval
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
ncat localhost 8888 |
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
while read line; do \ | |
sleep .7; \ | |
echo $line | \ | |
tr -d '\r' | \ | |
jq --compact-output --raw-input --raw-output 'split(",") | {"airline": .[0], "airlineId": (.[1]|tonumber? // null), "sourceAirport": .[2], "sourceAirportId": (.[3]|tonumber? // null), "destinationAirport": .[4], "destinationAirportId": (.[5]|tonumber? // null), "codeshare": .[6], "stops": (.[7]|tonumber? // null), "equipment": .[8]}'; \ | |
done < <(curl -s https://raw.githubusercontent.com/jpatokal/openflights/master/data/routes.dat) | \ | |
ncat -lk 8888 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reads the contents from a remote CSV, removes \r, creates a custom json record and starts streaming it with a fixed interval to port 8888 on localhost