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

151
Views
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 answers
Answer question

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 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!