Skip to content

Instantly share code, notes, and snippets.

@swuecho
Created June 8, 2012 03:49
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 swuecho/2893455 to your computer and use it in GitHub Desktop.
Save swuecho/2893455 to your computer and use it in GitHub Desktop.
convert all the xsl files to csv files in one directory
;;;convert all the xsl files to csv files in one directory
;get all the file names in one directory
(def directory (clojure.java.io/file "C:/Users/echo/Dropbox/7000/data-sets"))
(def files (file-seq directory))
(def filestr (map str files))
;find all the xls files in the directory
(def xlsfiles (filter #(re-find #".xls" %) filestr))
;clojure.string/replace
(defn xsl2csv [x] (save (read-xls x) (clojure.string/replace x #"xls" "csv")))
;convert all the xls file to csv files
(map xsl2csv xlsfiles)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment