Skip to content

Commit

Permalink
[simple-chart] Remove leading quotes from comment strings when excel …
Browse files Browse the repository at this point in the history
…sneaks them in (#6780)

* remove leading quotes from comment strings when excel sneaks them in

* More accurate regex replacement

* match first line quote

* handle first char and linebreak cases, with \n replacement as necessary
  • Loading branch information
wpears authored Dec 3, 2021
1 parent 9da614d commit 5601225
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ function fetchData( url, isCSV ) {

return prom.then( d => {
if ( isCSV ) {
/* Excel can put quotes at the start of our # or // comments
This strips those quotes */
d = d.replace( /^"(#|\/\/)|(\n)"(#|\/\/)/g, '$1$2$3' );
d = Papa.parse( d, {
header: true, comments: true, skipEmptyLines: true
} ).data;
Expand Down

0 comments on commit 5601225

Please sign in to comment.