I'm looking to find a neat way to create a comma-delimited string from an array. This is how I'm doing it now...
for(i=0;i<10;i++)
{
str = str + ',' + arr[i];
}
str=str.substring(1)
return str;
... but it feels a bit untidy.
Given a Set of String, the task is to convert the Set to a comma separated String in Java. Approach: This can be achieved with the help of join() method of String as follows. Get the Set of String. Form a comma separated String from the Set of String using join() method by passing comma ', ' and the set as parameters.
(adj.) Comma-delimited is a type of data format in which each piece of data is separated by a comma. This is a popular format for transferring data from one application to another, because most database systems are able to import and export comma-delimited data.
How to Convert a Python List into a Comma-Separated String? You can use the . join string method to convert a list into a string. So again, the syntax is [seperator].
Please follow these instructions: 1. Type the formula =CONCATENATE(TRANSPOSE(A1:A7)&",") in a blank cell adjacent to the list's initial data, for example, cell C1. (The column A1:A7 will be converted to a comma-serrated list, and the separator "," will be used to separate the list.)
Array.prototype.join()
is what you're looking for:
arr.join(',');
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/join
var arr = ['Hi', 'I', 'am', 'a', 'comma', 'separated', 'list'];
arr.join(','); // === "Hi,I,am,a,comma,separated,list"
Use the join method:
arr.join(',');
you have to use
var joinedstr = myarray.join(',');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With