Transposing a comma-separated string into a column in JSL<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />Hi folks,
I am want to transform a string that i am getting as an input from a text edit box such as a,b,c,d... into a column:
a
b
c
d
...
Any ideas?
Thanks,
David
Re: Transposing a comma-separated string into a column in JSLMany thanks
Re: Transposing a comma-separated string into a column in JSLIf all you want to do is save each entry in your original string into a separate line of a file, then there's a simpler way:
a = "a,b,c,d,e";
crlf = hextochar("0D") || hextochar("0A");
b = substitute(a, ",", crlf);
save text file("C:\b.txt", b);
Re: Transposing a comma-separated string into a column in JSLThis is exactly what i was looking for, thanks a bunch!
Unfortunately, i cannot make the next step which i thought to be trivial.
How can the column you called "My List" be saved as a text file? I used various combinations with the command save text file, but nothing worked. This is the only column in the data table, so saving the whole table would work as well.
Re: Transposing a comma-separated string into a column in JSLYou can use the WORDS function to parse the string into a list, and then add it as a new column.
a = words("a,b,c,d,e", ",");
n = nitems(a);
dt = new table("Untitled", add rows(n),
new column("My List", character, nominal, set values(a)));