Permalink
Browse files

functionally complete. Output is good. Now its time to clean up the c…

…ode and add record
  • Loading branch information...
rippinrobr committed Nov 13, 2011
1 parent 1664989 commit 3d15b27154dc34f73a81ace4695813dabc1e39ea
Showing with 8 additions and 3 deletions.
  1. +8 −2 hugoclr/data/csv.clj
  2. +0 −1 hugoclr/parser.clj
View
@@ -1,14 +1,20 @@
(ns hugoclr.data.csv)
+(defn clean
+ [val]
+ (.Replace (.Replace (.Replace (.Replace (.Replace val "," ";") "<em>" "") "</em>" "") "&#8217;" "'") "&amp;" "&"))
+
(defn delimit
[year books]
- (map #(str year "," (:winner %) "," (:title %) "," (:author %) "," (:publisher %) "\r\n") books))
+ (map #(str year "," (:winner %) ","
+ (clean (:title %)) ","
+ (:author %) ","
+ (clean (:publisher %)) "\r\n") books))
(defn write-to-file
[categories file-name]
(let [stream (System.IO.StreamWriter. file-name)
lines (map #(delimit (:year (first %)) (:books (first %))) categories)]
- (print lines)
(.Write stream (apply str (map #(reduce str "" %) lines)))
(.Close stream)))
View
@@ -49,7 +49,6 @@
(defn create-work-struct
[li-node]
- (println (.InnerHtml li-node))
(struct work (check-for-winner li-node) (get-work-title li-node)
(my-regex #".*</em>\s*(by|,)\s+(.*)\s+[\[\(].*" (.InnerHtml li-node))
(my-regex #".*[\(\[](.*)[\)\]].*" (.InnerHtml li-node))))

0 comments on commit 3d15b27

Please sign in to comment.