Skip to content

Instantly share code, notes, and snippets.

@nicholasf
Last active October 14, 2015 04:42
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 nicholasf/e8309e6b2ffea364654f to your computer and use it in GitHub Desktop.
Save nicholasf/e8309e6b2ffea364654f to your computer and use it in GitHub Desktop.
(defn to-zip
"Converts a clojure.data.xml load into a clojure.zip zipper"
[xml-data]
(-> xml-data czip/xml-zip))
(defn load-feed
"Loads the given filename"
[filename]
(-> filename
clojure.java.io/resource
clojure.java.io/input-stream
clojure.data.xml/parse))
(defn stream-as-agencies
"An example mapping function using xml-> and xml1-> zipping"
[listings-zip]
(let [agencies (take 5 (xml-> listings-zip :Agencies :Agency))]
(doseq [agency agencies])
(println "*")))
(defn two-gig-file
"The transformed sample data"
[]
(stream-as-agencies (to-zip (load-feed "Live.xml"))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment