- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Transposing a comma-separated string into a column in JSL
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
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Transposing a comma-separated string into a column in JSL
You 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)));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Transposing a comma-separated string into a column in JSL
You 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)));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Transposing a comma-separated string into a column in JSL
This 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Transposing a comma-separated string into a column in JSL
If 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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Transposing a comma-separated string into a column in JSL
Many thanks