Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

390
Views
Parse csv with line breaks in a single cell in google app script

I am trying to load some csv data onto spreadsheet. Unfortunately, I keep getting this error when I try to feed my csv data onto Utilities.parseCsv():

Exception: Could not parse text.

The payload for parseCsv looks something like this:

"\"colName1\", \"colName2\"\n, \"<some html>\n<more html>\", \"colVal2\"\n"

Initially, I thought it might be because there are some html stuff inside the csv data. However, after doing some more testing, I realized it's the \n that's screwing things up. That's because when I take out the \n<more html>\" part from that csv string, it's now able to parse my csv data. Is there a way to get around this without removing that portion of the payload?

My code is pretty simple but it looks like this:

 const response = UrlFetchApp.fetch(csvLink);
 const csvData = response.getContentText();
 const parsedCsvData = Utilities.parseCsv(csvData);

where csvLink is a url to the csv that allows users to grab the csv file/contents.

Essentially, I want to be able to parse my csv whilst being able to keep the line breaks present in a single cell.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Instead of using parseCsv(), I had to approach this problem in a different way since I couldn't just replace all \n with a different character. I ended up using batchUpdate() instead. This way, I was able to paste my csv data directly onto google spreadsheet in a more efficient manner.

Here is a pretty good github post that talks about different possible ways to write csv data onto google spreadsheet :

https://gist.github.com/tanaikech/030203c695b308606041587e6da269e7

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!