Is it possible to change the headers of a "csv" file to uppercase during the process performed by papa.parse using JavaScript?!
Thanks in advance.
PapaParse - Libraries - cdnjs - The #1 free and open source CDN built to make life easier for developers.
Papa Parse is the fastest in-browser CSV (or delimited text) parser for JavaScript. It is reliable and correct according to RFC 4180, and it comes with these features: Easy to use. Parse CSV files directly (local or over the network) Fast mode (is really fast)
To get started with Papa Parse, first import the library. import Papa from 'papaparse'; When using the parse function, you can either choose to parse a string of delimited text, a local file, or a remote file URL. For this example, we will be parsing a local file that we received from React Dropzone in part one.
beforeFirstChunk: function(chunk) {
var rows = chunk.split( /\r\n|\r|\n/ );
var headings = rows[0].toUpperCase();
rows[0] = headings;
return rows.join("\r\n");
},
supporting 'beforeFirstChunk' solved me this issue, nevertheless if you use 'worker: true' inside your configuration it will trigger an exception, looks like a known bug.
As of version 5.0, PapaParse now has transformHeader
, which is
A function to apply on each header. Requires header to be true. The function receives the header as its first argument. Only available starting with version 5.0.
You can see an example at Using PapaParse transformHeader to remove whitespace from headers?.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With