Skip to content

Conversation

@glenselle
Copy link

It's not uncommon for a CSV file to have strange or badly formatted column names. This PR adds a new transform function option (mapped to each column name) so column names can be overridden as needed. The default simply returns the existing value so nothing changes.

Usage might be something like this:

let parser = csv({
  columnTransform: function(name) {
    switch (name) {
      case 'some Weird Name':
        return 'new_name'
      default:
        return name
    }
  },
  columns: true
})

@klaemo
Copy link
Owner

klaemo commented Jan 27, 2017

Hey, thank you for the PR and sorry for the delayed response. Could you add a small test case to the tests, so we can make sure this feature doesn't break in the future?

Thanks!

@glenselle
Copy link
Author

@klaemo closing -- see PR #40 which has the same changes + tests

@glenselle glenselle closed this Mar 4, 2017
@glenselle glenselle deleted the column-name-map branch March 4, 2017 21:10
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.

2 participants