Skip to main content

I have a CSV file where one of the fields contains XY coordinate pairs. I want to use the AttributeSplitter to separate them so they can be mapped. Easy enough, no? Well, not so much if the coordinates are separated by an STX control character. I've tried several different ways in the Delimiter or Format String parameter of the AttributeSplitter but no luck. Does anyone know how I could?

Thanks,

Aaron Allen

If the X and Y values have a fixed length you could use the SubstringExtractor to get first the X and then the Y values in two steps.


That's a good idea @erik_jan but unfortunately the values are not a fixed length.


Or you can use the StringReplacer with the regular expression \\D (= anything but a digit) and replace with ";". Then you could use the AttributeSplitter on the ";". This will not work if decimals are involved.


Or you can use the StringReplacer with the regular expression \\D (= anything but a digit) and replace with ";". Then you could use the AttributeSplitter on the ";". This will not work if decimals are involved.

If you use the regex [^\\d.] all characters except digits and points (decimals) will be replaced.


Using the StringReplacer worked @erik_jan, although I had to search for anything other than a positive or negative number to any number of decimal digits so the regexp I used is [^-0-9.]

Note the above works for my data but it's not perfect in all cases. You can see what I mean if you use the expression at http://www.regexr.com/


As I understand it (though I haven't tried it) you could type \\cB to identify an STX character. It may even work directly in the AttributeSplitter

See: http://www.regular-expressions.info/nonprint.html


@Mark2AtSafe I tried \\cB and several others but no joy. I even tried copying and pasting the STX character from Notepad++. (I can do a find and replace in Notepad++ BTW.) The StringReplacer will work in this case so I'll go with that. Both [^-0-9.] and [^-\\d.] as @erik_jan offered work.


Reply