Created
April 16, 2020 08:33
-
-
Save robinclart/ef490fd1404341c8cd12297ef5048fd7 to your computer and use it in GitHub Desktop.
Convert data from covid19 stats for Thailand into a tab separated list that can be imported into a spreasheet
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
| require "excon" | |
| require "json" | |
| data = JSON.parse(Excon.get("https://covid19.th-stat.com/api/open/timeline").body) | |
| timeline = data["Data"].reverse.take(60).map do |day| | |
| [ | |
| day["Date"], | |
| day["NewConfirmed"], | |
| day["NewRecovered"], | |
| day["NewHospitalized"], | |
| day["Confirmed"], | |
| day["Recovered"], | |
| day["Hospitalized"], | |
| day["Deaths"], | |
| ].join("\t") | |
| end | |
| puts ["Date", "NewConfirmed", "NewRecovered", "NewHospitalized", "Confirmed", "Recovered", "Hospitalized", "Deaths"].join("\t") | |
| puts timeline.reverse.join("\n") |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use with
ruby convert-to-table.rb | pbcopyNote: remove
| pbcopyif not on a mac. And make sure to haveexconinstalled.