From bbdf6d8364df8a67a55bddb0299f5cb058f15a24 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Mon, 27 Jan 2020 13:29:45 +0000 Subject: [PATCH 1/3] lein-release plugin: bumped version from 0.1.4 to 0.1.5-SNAPSHOT for next development cycle --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index 2157956..6e797bb 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject csv2edn "0.1.4" +(defproject csv2edn "0.1.5-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 eed97039c92e91d3d46e79ad1b862b2dd5775564 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Mon, 27 Jan 2020 13:53:05 +0000 Subject: [PATCH 2/3] Fixed dodgy characters in column headers --- README.md | 26 +++++++++++++++++--------- src/csv2edn/csv2edn.clj | 6 ++++-- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 182b352..db5b6b9 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,44 @@ # csv2edn -Simple command line utility to convert CSV files to EDN. Assumes the first row of a CSV file contains column headers. +Simple command line utility and library to convert +[comma-separated value (CSV)](https://tools.ietf.org/html/rfc4180) files to +[extensible data notation (EDN)](https://github.com/edn-format/edn) or +[javascript object notation (JSON)](https://www.json.org/json-en.html). Assumes +the first row of a CSV file contains column headers. ## Installation [![Clojars Project](https://img.shields.io/clojars/v/csv2edn.svg)](https://clojars.org/csv2edn) +**NOTE**: if the version numbers given below differ from the number in the +image above, the image (which is automatically generated) is correct and +this file (which is manually maintained) is in error. + ### Leiningen/Boot -[csv2edn "0.1.4"] +[csv2edn "0.1.5"] ### Clojure CLI/deps.edn -csv2edn {:mvn/version "0.1.4"} +csv2edn {:mvn/version "0.1.5"} ### Gradle -compile 'csv2edn:csv2edn:0.1.4' +compile 'csv2edn:csv2edn:0.1.5' ### Maven csv2edn csv2edn - 0.1.4 + 0.1.5 ## Usage: as a standalone commandline tool To run from the command line: - $ java -jar csv2edn-0.1.4-standalone.jar [options] + $ java -jar csv2edn-0.1.5-standalone.jar [options] ### Options @@ -51,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.4-standalone.jar > path/to/file.edn + java -jar csv2edn-0.1.5-standalone.jar > path/to/file.edn Exactly the same behaviour can be achieved by specifying input and output paths: - $ java -jar csv2edn-0.1.4-standalone.jar \ + $ java -jar csv2edn-0.1.5-standalone.jar \ -i path/to/file.csv -o path/to/file.edn or - $ java -jar csv2edn-0.1.4-standalone.jar \ + $ java -jar csv2edn-0.1.5-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 4e29b7d..eb6f682 100644 --- a/src/csv2edn/csv2edn.clj +++ b/src/csv2edn/csv2edn.clj @@ -4,7 +4,7 @@ [clojure.data.json :as json] [clojure.java.io :as io] [clojure.pprint :refer [pprint]] - [clojure.string :refer [lower-case]])) + [clojure.string :as s])) (def ^:dynamic *options* "Defaults for options used in conversion (essentially, `:separator` is `,`, @@ -33,7 +33,9 @@ (csv/read-csv reader :separator (first (str sep))))) - headers (map #(keyword (lower-case %)) (first data)) + headers (map #(keyword + (s/replace (s/lower-case %) #"[^a-z0-9]" "-")) + (first data)) result (map #(zipmap headers (map maybe-read %)) (rest data))] From 5da08bcf585639272118c755b04ebeedcc3f5811 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Mon, 27 Jan 2020 13:53:19 +0000 Subject: [PATCH 3/3] lein-release plugin: preparing 0.1.5 release --- project.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project.clj b/project.clj index 6e797bb..02b20de 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject csv2edn "0.1.5-SNAPSHOT" +(defproject csv2edn "0.1.5" :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"