Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

149
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda