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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add index argument to "transformHeader" config function #807

Merged
merged 1 commit into from Jun 24, 2020

Conversation

furey
Copy link
Contributor

@furey furey commented Jun 24, 2020

When transforming headers, knowing what column index a header refers to can be extremely useful.

This PR adds the header index as an optional second argument to the transformHeader config function.

This PR also corrects the addHeder typo (changed to addHeader).

Cheers!

馃馃憤

@furey furey changed the title Add index to "transformHeader" method Add index argument to "transformHeader" config function Jun 24, 2020
@pokoli pokoli merged commit 018f5df into mholt:master Jun 24, 2020
@pokoli
Copy link
Collaborator

pokoli commented Jun 24, 2020

Hi @furey,

Thanks for your contribution.

@fabiendeborde
Copy link

Hello and thank you very much for this library and this update, I would really really like to start using this functionality but it seems there was no npm update since it was merged into master.
Is there any way to be able to use this (beside forking the repository) ?

@pokoli
Copy link
Collaborator

pokoli commented Jul 14, 2020

@fabiendeborde as the code is merged into master branch you can build your own papaversion from there.

@fabiendeborde
Copy link

@pokoli Thank you for your answer. I ended up forking the master branch so I could use npm without having to worry about future updates on the master branch that could contain breaking changes.

By the way, I tried to use the updated transformHeader that should contain the index, but index still returns undefined.
I am using the code below, if you have time, can you please tell me if I am doing something wrong?

Papa.parse(file, {
      skipEmptyLines: true,
      header: true,
      transformHeader: (header, index) => {
        console.log('header', header)
        console.log('index', index)
      }
      complete: onComplete,
      error: onError
})

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.

None yet

3 participants