Created
December 14, 2014 13:22
-
-
Save jamesdavidson/af2030b70d5849f9d344 to your computer and use it in GitHub Desktop.
Amateur Lisp
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
; 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