Hi Gabriel,
the ImageJ 'split' (in ij.util.Tools) function uses the StringTokenizer, not the String.split function. Thus, multiple occurrences of the same delimiter are taken as one. Especially with whitespace characters as separators, this is usually the desired behavior.
I fear that changing this may break existing macros that rely on the current split function.
A way out would be having a second split function with a different name or a split function that behaves like String.split, but I don't know whether it's worth while.
A workaround might be adding spaces between the commas:
s="1,2,3,,5,,,8,,,,12,,,,,17";
s1=replace(replace(s,",,",", ,"),",,",", ,");
print(s1);
a=split(s1,",");
print(lengthOf(a));
Michael
________________________________________________________________
On Jul 23, 2014, at 18:08, Gabriel Schweighauser wrote:
> Dear List,
>
> The built-in macro language function shows an unexpected behaviour if an
> "empty" column is present in the string.
>
> Example:
>
> split("1,2,3,,5",",");
>
> returns the same array as:
>
> split("1,2,3,5",",");
>
> Hence, parsing tables with "empty" cells from csv-files does not work.
>
> Is there a way to fix this?
>
> We're using ImageJ 1.49b.
>
>
> Thanks for your reply,
> Gabriel
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html