diff --git a/README.md b/README.md index db5b6b9..0e49d83 100644 --- a/README.md +++ b/README.md @@ -16,29 +16,29 @@ this file (which is manually maintained) is in error. ### Leiningen/Boot -[csv2edn "0.1.5"] +[csv2edn "0.1.6"] ### Clojure CLI/deps.edn -csv2edn {:mvn/version "0.1.5"} +csv2edn {:mvn/version "0.1.6"} ### Gradle -compile 'csv2edn:csv2edn:0.1.5' +compile 'csv2edn:csv2edn:0.1.6' ### Maven csv2edn csv2edn - 0.1.5 + 0.1.6 ## Usage: as a standalone commandline tool To run from the command line: - $ java -jar csv2edn-0.1.5-standalone.jar [options] + $ java -jar csv2edn-0.1.6-standalone.jar [options] ### Options @@ -59,17 +59,17 @@ Where options are: The simplest possible use is to simply use this in a pipeline: $ cat path/to/file.csv |\ - java -jar csv2edn-0.1.5-standalone.jar > path/to/file.edn + java -jar csv2edn-0.1.6-standalone.jar > path/to/file.edn Exactly the same behaviour can be achieved by specifying input and output paths: - $ java -jar csv2edn-0.1.5-standalone.jar \ + $ java -jar csv2edn-0.1.6-standalone.jar \ -i path/to/file.csv -o path/to/file.edn or - $ java -jar csv2edn-0.1.5-standalone.jar \ + $ java -jar csv2edn-0.1.6-standalone.jar \ --input path/to/file.csv --output path/to/file.edn ## Usage: as a library diff --git a/project.clj b/project.clj index 02b20de..6fd7df0 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject csv2edn "0.1.5" +(defproject csv2edn "0.1.6" :description "Simple command line utility to convert CSV files to EDN." :url "https://github.com/simon-brooke/csv2edn" :license {:name "GPL-2.0-or-later WITH Classpath-exception-2.0" diff --git a/src/csv2edn/csv2edn.clj b/src/csv2edn/csv2edn.clj index eb6f682..96db0cd 100644 --- a/src/csv2edn/csv2edn.clj +++ b/src/csv2edn/csv2edn.clj @@ -14,9 +14,16 @@ (defn maybe-read "If a string represents an integer or real, we'd really like to have that integer or real in our data rather than a string representation of it." + ;; TODO: this is actually quite difficult and the current solution won't + ;; correctly handle numbers in scientific notation, ratios, or imaginary + ;; numbers. [^String s] (try - (read-string s) + (if + (re-matches #"^ *[+-]?[0-9]*\.?[0-9]*" s) + (let [v (read-string s)] + (if (number? v) v s)) + s) (catch Exception _ s))) (defn csv->edn