Skip to content

Conversation

@ABeltramo
Copy link

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

@metasoarous
Copy link
Owner

Thanks for the PR!

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

Thanks again

@ABeltramo
Copy link
Author

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

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

Successfully merging this pull request may close these issues.

mappify should set missing values (for rows shorter than header) to nil

2 participants