semantic-csv icon indicating copy to clipboard operation
semantic-csv copied to clipboard

fix: added nil to empty values

Open ABeltramo opened this issue 6 years ago • 2 comments

I changed the zipmap default method so that it will always create a map with all the passed keys. Another solution can be:

(defn pad [n coll val]
        (take n (concat coll (repeat val))))

(defn mappify-row
  "Translates a single row of values into a map of `colname -> val`, given colnames in `header`."
  [header row]
  (zipmap header (pad (count header) row nil))) ; here we can replace nil with any default value passed by the user

Fixes #65

ABeltramo avatar Jun 11 '19 08:06 ABeltramo

Thanks for the PR!

See comments in #65; This is great, but would you please make this functionality opt-in only?

Thanks again

metasoarous avatar Jun 13 '19 21:06 metasoarous

There you go, added :preserve-header to the mappify options.

ABeltramo avatar Jun 15 '19 07:06 ABeltramo