10

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.

Biryukov Pavel
  • 397
  • 4
  • 18

2 Answers2

14
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.

Biryukov Pavel
  • 397
  • 4
  • 18
3

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?.

Jason
  • 514
  • 5
  • 21