Skip to main content

Hi, I have a text string that looks something like this…

LOT 4-6 DP 287 SEC 2-3 SO 345152 

I have a regex “(LOT \d+T\s?&-]\d+ DP \d+ ){1,}”  that grabs the LOT 4-6 DP 287 from the text line.

How can I split the 4-6 into separate attributes so I end up with 

  • Lot 4 DP 287
  • Lot 5 DP 287
  • Lot 6 DP 287

I could do it with a testfilter but there are unknown combinations. 1-12, 60-62, 78-82 etc

Any help is greatly appreciated.

Regards, Paul

hi, other ways are possible and probably more efficient, but this might get you in the right direction?

The value LOT 4-6 DP 287 is in an attribute ‘test’ to start with, ends up with 3 features:

 


First use a StringSearcher to Regex Search the LOT_RANGE (second part of your LOT_CODE)

Then Split the LOT_RANGE on the minus to get the LOT_LIST containing 2 values

Then calculate the length of the LOT (RANGE_AMOUNT)=RANGE_LIST{1}-RANGE_LIST{0}+1

Then clone your features by RANGE_AMOUNT and store the RANGE_OFFSET (clone-index)

Then make the LOT_NUM=RANGE_LIST{0}+RANGE_OFFSET

And finaly you could StringReplace the LOT_RANGE in your string with the LOT_NUM. But don't know if you want to do it like that:

Result:

 


You @becchr beat me on time. Should have refreshed the page.

 

Almost exactly the same solution. My AttributeCreator_5 is integrated in your StringReplacer.

And my StringSearcher is only looking for Ranges after the word LOT.

I can imagine somewhere down the line you want every part of the LOT_CODE to be in separate columns. So you would split everything in the right column to start, but if this is the final result, this is a solution.


Thank you both for your time. Exactly what I was after and would have taken me days.

You guys rock!

Regards, Paul


Reply