Skip to content

Instantly share code, notes, and snippets.

@jamesdavidson
Created December 14, 2014 13:22
Show Gist options
  • Save jamesdavidson/af2030b70d5849f9d344 to your computer and use it in GitHub Desktop.
Save jamesdavidson/af2030b70d5849f9d344 to your computer and use it in GitHub Desktop.
Amateur Lisp
; scrape some VCF in to Clojure data
(def raw_data (slurp "/Users/jd/Documents/contacts_dump.vcf"))
(defn deets [args]
{ :name (first (filter #(re-matches #"FN.*" %) args))
:number (first (filter #(re-matches #"TEL.*" %) args))})
(def contacts
(map deets
(partition-by #(= % "END:VCARD")
(clojure.string/split-lines raw_data))))
(defn missing_data? [rec]
(or
(nil? (:name rec))
(nil? (:number rec))))
(def contacts_present
(filter (comp not missing_data?) contacts))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment