Skip to main content
Solved

Copying values from one list to another


darren
Contributor
Forum|alt.badge.img+6

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

Best answer by takashi

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)
View original
Did this help you find an answer to your question?

4 replies

Forum|alt.badge.img
  • July 20, 2016

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


takashi
Evangelist
  • Best Answer
  • July 20, 2016

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)

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • July 20, 2016

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.


darren
Contributor
Forum|alt.badge.img+6
  • Author
  • Contributor
  • July 26, 2016

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.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings