transformHeader called twice
Author: kiocosCreated Nov 8, 2023Updated Mar 20, 2026
I have this sample code
let counter = 0;
let csv = "First name,Last name\nJohn,Doe"
let json = Papa.parse(csv, {
header: true,
transformHeader: (header, a) => {
counter++;
console.log(a);
return header;
},
});
console.log({ counter })This is the result from running it:
It's interesting that the second argument starts as a string and then becomes a number. I think this suggests transformHeader is being executed from different lines each time.
Logging "header" returns this: "First name" "Last name" "First name" "Last name"
It seems like transformHeader is executed twice for the first row. This is causing a bug in my application and I don't know why this behavior is happening.
I'd really appreciate some help with it. Thanks in advance!!
Source: mholt/PapaParse