From b5c6b5d7a5992ad66f41012d693886b538669885 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Mon, 27 Jan 2020 13:53:51 +0000 Subject: [PATCH 1/4] lein-release plugin: bumped version from 0.1.5 to 0.1.6-SNAPSHOT for next development cycle --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index 02b20de..a4d3fb4 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject csv2edn "0.1.5" +(defproject csv2edn "0.1.6-SNAPSHOT" :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" From 837c43ac32197d03d4e2816718c5c89a58c1da71 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Mon, 27 Jan 2020 15:48:11 +0000 Subject: [PATCH 2/4] Fixed bug in reading string values but still buggy if first character is digit --- src/csv2edn/csv2edn.clj | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/csv2edn/csv2edn.clj b/src/csv2edn/csv2edn.clj index eb6f682..19aff49 100644 --- a/src/csv2edn/csv2edn.clj +++ b/src/csv2edn/csv2edn.clj @@ -16,7 +16,8 @@ integer or real in our data rather than a string representation of it." [^String s] (try - (read-string s) + (let [v (read-string s)] + (if (number? v) v s)) (catch Exception _ s))) (defn csv->edn From a178270a758f106536fe9e243cafc14d05a8df10 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Mon, 27 Jan 2020 15:59:17 +0000 Subject: [PATCH 3/4] Now more or less correctly handles strings which start with a number. --- README.md | 16 ++++++++-------- src/csv2edn/csv2edn.clj | 10 ++++++++-- 2 files changed, 16 insertions(+), 10 deletions(-) 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/src/csv2edn/csv2edn.clj b/src/csv2edn/csv2edn.clj index 19aff49..96db0cd 100644 --- a/src/csv2edn/csv2edn.clj +++ b/src/csv2edn/csv2edn.clj @@ -14,10 +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 - (let [v (read-string s)] - (if (number? v) v 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 From fc446a163d06f7e5d27e713c308b619fbfeb4c07 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Wed, 29 Jan 2020 09:46:07 +0000 Subject: [PATCH 4/4] lein-release plugin: preparing 0.1.6 release --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index a4d3fb4..6fd7df0 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject csv2edn "0.1.6-SNAPSHOT" +(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"