Skip to content

Instantly share code, notes, and snippets.

@simonjamain
Last active April 26, 2022 00:45
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save simonjamain/7e23b898527655609e5ff012f412dd50 to your computer and use it in GitHub Desktop.
Save simonjamain/7e23b898527655609e5ff012f412dd50 to your computer and use it in GitHub Desktop.
fix the bug on Utilities.parseCsv() google script function which does not allow newlines in csv strings
function parseCsv(csvString, delimiter) {
var sanitizedString = csvString.replace(/(["'])(?:(?=(\\?))\2[\s\S])*?\1/g, function(e){return e.replace(/\r?\n|\r/g, ' ') });
return Utilities.parseCsv(sanitizedString, delimiter)
}
@dexterlabora
Copy link

Saved me a ton of time troubleshooting. Thanks :)

@alsteven
Copy link

This was super helpful, thank you for posting.

@webmasterjunkie
Copy link

Same. Thanks for sharing.

@milliethe
Copy link

you are my hero of the day, thanks!!

@Entreaguas
Copy link

Thank you!

@dmkoluk
Copy link

dmkoluk commented Mar 5, 2021

Super helpful. Thank you!

@miking7
Copy link

miking7 commented Mar 25, 2021

Thanks Simon - I had been using a similar solution from: https://stackoverflow.com/a/60286433 ... but it was failing in some circumstances.

@TakahisaHayashi
Copy link

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment