Solved

Copying values from one list to another


Badge +1

Hi, I have a list of dates in a list called _inputlist, I then need to run these sequentially through a loop and test each entry to see whether it is in the past, is today or in the future. This much is easy enough as I can create a custom transformer, use the DateDifferenceCalculator to calculate the number of days between the date value of the list item and the value of a TimeStamper and then test for values => 0.

The next part is the one I am having trouble with. I would like to store those dates that pass the tester into another list (called _outputlist) but I'm not sure how to assign the values to this list.

As an example, this is how I would like it to work;

_list{0} = _outputlist{0}

 

_list{1} = (failed tester, discard value)

 

_list{2} = _outputlist{1}

 

_list{3} = (failed tester, discard value)

 

_list{4} = _outputlist{2}

 

_list{5} = (failed tester, discard value)

I suppose I want something that will allow me to set @Value(_outputlist{@Value(_outputcounter)}) = @Value(_list{@Value(_counter)}) with _outputcounter and _counter being controlled independently.

I've tried AttributeCreator but whilst I can enter @Value(_list{@Value(_counter)}) as the Attribute Value I don't seem to be able to enter a similar expression in the New Attribute column.

I'm probably missing something simple but any assistance would be appreciated.

Many thanks

Darren

icon

Best answer by takashi 20 July 2016, 17:06

View original

4 replies

Badge

Hello Darren,

Maybe you can assign a unique id to each feature and use a ListExploder to break _list into features.

Then test for you dates and discard unwanted dates.

Finally use a ListBuilder grouping by your unique id to create _outputlist with the remaining dates.

Regards,

Larry

Userlevel 2
Badge +17

Hi @darren, if all the failed element values are identical, a ListCopier and a ListElementFilter (FME Hub ) might be helpful. The parameters for the ListElementFilter may be:

  • Filter Type: Exact Match
  • Match Expression: <the value that indicates failed elements>
  • Negate Filtering Condition: Yes (keep only elements that don't match the value)
Badge +3

explode it and create new list grouped by passed criteria and some ID as suggested.

In the new attribute column you would have to type (can't select it):

@Value(@Value(someattriubte))

in your case it would be @Value(@Value()}))

Wich then forces you to expose them. Would'nt do that unless you see no oter way.

Badge +1

Many thanks for the responses, @takashi seemed to provide the simplest solution with some minor tweaks;

  • Filter Type: Numeric Range
  • Match Expression: (,@Value(_timestamp))
  • Negate Filtering Condition: Yes

This filters out all list elements where the value is less than the value of _timestamp (i.e. in the past). I was initially concerned that the Numeric Range option would only provide a straight 'less than' filter but it looks like the results are coming out as 'less than or equal to', which is exactly what I was after.

Reply