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

fix: added nil to empty values #66

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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