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

148
Vistas
Convert a array of strings into string for the csv

I have following array of strings.

 const test = ["Date,type,user,Account,Desc\r",
    "1 jan 2021,RR,GK,,Testing acc\r",
    "1 jan 2021,RR,GK,,Testing acc\r",
    "1 jan 2021,RR,GK,,Testing acc\r",
    "1 jan 2021,RR,GK,,Testing acc\r"]

Now I am trying to convert this array of string into the a single string which can then used for CSV creation.

So I tried test.toString() which resulted into

"Date,type,user,Account,Desc
,1 jan 2021,RR,GK,,Testing acc
,1 jan 2021,RR,GK,,Testing acc
,1 jan 2021,RR,GK,,Testing acc
,1 jan 2021,RR,GK,,Testing acc
"
After using this data for CSV creation , it is actually skipping one column means Date date gets added in the next column and last data which is Testing acc does not contain any header it should have been Desc.

If I remove the the , before every 1 jan 2021 then it takes all columns properly but the date should have been ###### instead it takes the original value.

How do I fix this ?

Thanks

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try to use the join method:

const separator = '\n'; // or select enother value
test.join(separator)

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join

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