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