Skip to main content

Hi all,

I'm am looking for some Regex help to clean up my workflow.

 

I have used StringConcatenator to bring together latitude / longitude fields and to separate these with ", " (comma white space)

Unfortunately my data also contained empty fields and text resulting in:

, 51.50757358840452, 4.358557125886925aan, Alphen, Winterswijk

 

The only data I want to keep are the valid latlongs in bold.

 

Can you help me out with a regex string (to be used in StringReplacer) that cleans all except the valid latlongs?

Best,

Ed

I try and avoid regexes as much as I can, so in this case I would look at the AttributeSplitter, assuming the number of fields is always the same (and they're always in the same order) it should handle empty fields just fine. It'll then generate a list from which you can pick the relevant itels as your lat/lons.


Hi @edhere, alternatively, you can determine if the latitude and longitude values are valid as numeric representation with the AttributeValidator and then create the new attribute by concatenating them only if both were valid.

 


Hi @edhere, alternatively, you can determine if the latitude and longitude values are valid as numeric representation with the AttributeValidator and then create the new attribute by concatenating them only if both were valid.

 

An advantage of the AttributeValidator is that you can also validate range of individual numeric values simultaneously like this, if necessary.

 


It looks as if you have a newline character could you try to search and replace NL with nothing? using the stringreplacer


Hi Ed,

this should work, at least for your example: 

^,.*|\D+,^ ]\D+

But maybe it's easier to get rid of the problem before you use the StringConcatenator ...

Best,

Andre


Hi @edhere

I am a big fan of conditional values so I would use conditional values while getting the concatenated value (with e.g. AttributeCreator). The new concatenated LatLon value would be:

A closer look at the condition:


Hi Ed,

this should work, at least for your example: 

^,.*|\D+,^ ]\D+

But maybe it's easier to get rid of the problem before you use the StringConcatenator ...

Best,

Andre

Hi Andre,

 

 

Thanks, this worked for now!

 

I'll look at the other comments here to try and clean up my data before using the StringConcatenator.

 

 

Best,

 

Ed

 

 


Reply