Skip to content

Instantly share code, notes, and snippets.

@simonjamain
Last active April 26, 2022 00:45
Show Gist options
  • Select an option

  • Save simonjamain/7e23b898527655609e5ff012f412dd50 to your computer and use it in GitHub Desktop.

Select an option

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
Copy Markdown

Saved me a ton of time troubleshooting. Thanks :)

@alsteven

Copy link
Copy Markdown

This was super helpful, thank you for posting.

@webmasterjunkie

Copy link
Copy Markdown

Same. Thanks for sharing.

@milliethe

Copy link
Copy Markdown

you are my hero of the day, thanks!!

@Entreaguas

Copy link
Copy Markdown

Thank you!

@dmkoluk

dmkoluk commented Mar 5, 2021

Copy link
Copy Markdown

Super helpful. Thank you!

@miking7

miking7 commented Mar 25, 2021

Copy link
Copy Markdown

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
Copy Markdown

Thank you!

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