Created
March 21, 2020 16:55
-
-
Save munen/8fa2ea0d3d66974f7915e76c651fa502 to your computer and use it in GitHub Desktop.
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
(ns corona-stats.core | |
(:require [clojure.data.csv :as csv])) | |
(def csv-link "https://docs.google.com/spreadsheets/d/e/2PACX-1vQU0SIALScXx8VXDX7yKNKWWPKE1YjFlWc6VTEVSN45CklWWf-uWmprQIyLtoPDA18tX9cFDr-aQ9S6/pub?single=true&output=csv") | |
(def raw-data (slurp csv-link)) | |
(defn csv-data->maps [csv-data] | |
(map zipmap | |
(->> (first csv-data) ;; First row is the header | |
(map keyword) ;; Drop if you want string keys instead | |
repeat) | |
(rest csv-data))) | |
(def parsed-data (csv/read-csv (clojure.string/join | |
(drop | |
;; The first line is bogus and obscures the keys | |
1 | |
(clojure.string/split raw-data #"\n" ))))) | |
(def mapped-data (csv-data->maps parsed-data)) | |
(count mapped-data ) | |
(keys (first mapped-data)) | |
;; (:reporting date :from Wuhan :traveler :domestic_traveler :age :exposure_start :hosp_visit_date :symptom_onset :source :exposure_end :case_in_country :visiting Wuhan :summary :symptom :recovered :link :id :If_onset_approximated :gender :death :location :country :international_traveler) | |
(defn cases-in [country] | |
(filter #(clojure.string/includes? | |
(clojure.string/lower-case %) | |
country) | |
(map (juxt :country :location :summary) mapped-data))) | |
(count (cases-in "switzerland")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment