Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different results csv-map versus clojure-csv #8

Open
krisleech opened this issue Mar 17, 2017 · 2 comments
Open

Different results csv-map versus clojure-csv #8

krisleech opened this issue Mar 17, 2017 · 2 comments

Comments

@krisleech
Copy link

(first (csv-map.core/parse-csv (slurp "db/etr.csv")))

;; {"" "BURSLEDON ROAD", "Y55" "Y57", "WORCESTERSHIRE" "HAMPSHIRE", "WORCESTER" "SOUTHAMPTON", "ISAAC MADDOX HOUSE" "SOLENT NHS TRUST HEADQUARTERS", "WORCESTERSHIRE HEALTH AND CARE NHS TRUST" "SOLENT NHS TRUST", "Q77" "Q70", "WR4 9RW" "SO19 8BR", "F" "J", "20110701" "20110401", "R1A" "R1C", "0" "0", "SHRUB HILL INDUSTRIAL ESTATE" "HIGHPOINT VENUE"}
(first (clojure-csv.core/parse-csv (slurp "db/etr.csv")))

;; ["R1A" "WORCESTERSHIRE HEALTH AND CARE NHS TRUST" "Y55" "Q77" "ISAAC MADDOX HOUSE" "SHRUB HILL INDUSTRIAL ESTATE" "" "WORCESTER" "WORCESTERSHIRE" "WR4 9RW" "20110701" "" "" "" "" "" "" "" "" "" "" "0" "" "F" "" "" ""]

The second example using clojure-csv.core is correct. The columns are in the wrong order in the first example.

The source CSV looks like this:

"R1A","WORCESTERSHIRE HEALTH AND CARE NHS TRUST","Y55","Q77","ISAAC MADDOX HOUSE","SHRUB HILL INDUSTRIAL ESTATE","","WORCESTER","WORCESTERSHIRE","WR4 9RW","20110701","","","","","","","","","","","0","","F","","",""
"R1C","SOLENT NHS TRUST","Y57","Q70","SOLENT NHS TRUST HEADQUARTERS","HIGHPOINT VENUE","BURSLEDON ROAD","SOUTHAMPTON","HAMPSHIRE","SO19 8BR","20110401","","","","","","","","","","","0","","J","","",""
"R1D","SHROPSHIRE COMMUNITY HEALTH NHS TRUST","Y55","Q76","WILLIAM FARR HOUSE","MYTTON OAK ROAD","","SHREWSBURY","SHROPSHIRE","SY3 8XL","20110701","","","","","","","","","","","0","","E","","",""
@aaronblenkush
Copy link

I also got similar results with out of order columns.

@duchenne
Copy link

In reply to the above:

The source CSV above lacks a header row.

As per the doc, csv-map uses the first line of the csv file as column headers; i.e. the first row is turned into map keys and subsequent rows are turned into map values.

As far as I can see, csv-map performed as expected over the source CSV above i.e. it interpreted the first row as header / map keys.

The outputs of clojure-csv and csv-map are supposed to be different; clojure-csv returns a list of vecs whereas csv-map returns a list of maps, hence the difference you've observed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants