tangled
alpha
login
or
join now
m1emi1em.dev
/
bb-scripts
0
fork
atom
this repo has no description
0
fork
atom
overview
issues
pulls
pipelines
use a map and get instead of filter for csv lookups
m1emi1em.dev
1 year ago
ad75e97f
58be3775
+6
-6
1 changed file
expand all
collapse all
unified
split
weather
weather.bb
+6
-6
weather/weather.bb
···
39
39
([] (read-csv-to-maps (get-geonames-data-path)))
40
40
([fname]
41
41
(let [csv-data (-> fname slurp (csv/read-csv :separator \tab))]
42
42
-
(map #(zipmap [:postal_code :place_name :state_code :latitude :longitude]
43
43
-
(->> (get-all % [1 2 4 9 10]) (map second))) csv-data))))
42
42
+
(->> csv-data
43
43
+
(map #(zipmap [:postal_code :place_name :state_code :latitude :longitude]
44
44
+
(->> (get-all % [1 2 4 9 10]) (map second))))
45
45
+
(map #(->> % ((juxt :postal_code identity)) (apply hash-map)))
46
46
+
(into {})))))
44
47
45
45
-
(defn geocode [zipcode]
46
46
-
(first (filter
47
47
-
(fn [{zc :postal_code}] (= zc zipcode))
48
48
-
(read-csv-to-maps))))
48
48
+
(defn geocode [zipcode] (-> (read-csv-to-maps) (get zipcode)))
49
49
50
50
(defn check-rc []
51
51
(let [path (str (fs/home) "/.weatherrc")]