Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

393
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda