Skip to content

Instantly share code, notes, and snippets.

@rafaelrinaldi
Created November 16, 2017 19:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rafaelrinaldi/68ccefb3a23ccce09919f745114dac3b to your computer and use it in GitHub Desktop.
Save rafaelrinaldi/68ccefb3a23ccce09919f745114dac3b to your computer and use it in GitHub Desktop.
(defn str->num [x]
(-> (NumberFormat/getInstance (Locale/forLanguageTag "en-US")) (.parse x)))
(defn numeric? [x]
(try
(str->num x)
(catch ParseException pe false)))
(defn vector-of-vectors? [x]
(every? vector? x))
(defn cell-text [list]
(mapv #(:text %) list))
;; Make sure the list has only one level as the spreadsheet generator expects
(defn normalize [list]
(reduce (fn [acc x]
(if (vector-of-vectors? x)
(into acc x)
(conj acc x)))
[], list))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment