Skip to content

Instantly share code, notes, and snippets.

@zwang
Created September 7, 2014 15:01
Show Gist options
  • Save zwang/ef7a08aae2ba44386c8a to your computer and use it in GitHub Desktop.
Save zwang/ef7a08aae2ba44386c8a to your computer and use it in GitHub Desktop.
convert a file with word on each line to a json array. (pick only the first 2000 words)
(defn convert [](with-open [rdr (reader "/Users/zhaowang/workspace/clojure/labrepl/data/words")]
(doseq [line (take 2000 (line-seq rdr))]
(writeToFile (str "\"" line "\"" ",")))))
(defn writeToFile [line]
(with-open [wrtr (writer "test.json" :append true)]
(.write wrtr line)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment