Commits

Miki Tebeka  committed 390d849

Map records work

  • Participants
  • Parent commits 5ee3675
  • Branches write

Comments (0)

Files changed (2)

File src/csvlib.clj

 (defn vectorize-headers 
   "Return a vector of headers keys sorted by values"
   [headers]
-  (map first (sort-by headers headers)))
+  (vec (map first (sort-by headers headers))))
 
 (defn- gen-headers 
   "Generate headers for combinations of headers supplied by the user (which can
   "Sort record by headers. Return a sequence of values."
   [record headers]
   (when (unknowns? record headers) (throw (Exception. "unknown fields")))
-  (map #(get % record nil) headers))
+  (map #(get record % nil) headers))
 
 (defn- gen-values 
   "Generate values seq from a record."

File test/csvlib_test.clj

     (write-csv [[1 2 3] [4 5 6]] tmp :format format)
     (is (= (slurp tmp) "format-1,2,3\nformat-4,5,6\n"))))
 
-;(defwriter-test test-write-mapseq
-;  (write-csv [{"x" 1 "y" 2} {"x" 3 "y" 4}] tmp))
+(defwriter-test test-write-mapseq
+  (write-csv [{"x" 1 "y" 2} {"x" 3 "y" 4}] tmp)
+  (is (= (slurp tmp) "x,y\n1,2\n3,4\n")))