Skip to main content
Solved

Extracting range of attribute values


fmeuser_gc
Contributor
Forum|alt.badge.img+8

I have a col A which has values from 1-5. Can we get the list of all values of col A from 1-5. If so, could you please help me with the logic.

Thanks!

Best answer by lenaatsafe

Hi @fmeuser_gc

one more possible approach could be to:

  • create a copy of the original feature for each value in the EVENTIDRAN range;
  • calculate the corresponding range value for each copy;
  • merge all copies into single feature and store all range values as a list.

This will allow you to process ranges that include different number of values.

View original
Did this help you find an answer to your question?

18 replies

takashi
Influencer
  • October 2, 2017

I can see two numbers concatenated with a hyphen for each cell in the col A (EVENTIDRAN field).

"737055 - 737060""737061 - 737066", ...
Do you need to get all the individual values from them?
"737055""737060""737061""737066", ...

rylanatsafe
Safer
Forum|alt.badge.img+13
  • Safer
  • October 2, 2017

Hi @fmeuser_gc - I feel that there will be more than one solution,.. but here is an example workspace template that you can use or build upon. This workspace will add attributes _valx for each integer in the range defined by EVENTIDRAN.

Edit: This workspace was built with FME 2017.1.1 Build 17650 – if incompatible with your FME, the meat and bones of this workspace is included in the image below!

example-extractvaluefromrange.fmwt

Note: It relies on the values of EVENTIDRAN to always be a range that covers six integers, inclusive.


Forum|alt.badge.img
  • Best Answer
  • October 2, 2017

Hi @fmeuser_gc

one more possible approach could be to:

  • create a copy of the original feature for each value in the EVENTIDRAN range;
  • calculate the corresponding range value for each copy;
  • merge all copies into single feature and store all range values as a list.

This will allow you to process ranges that include different number of values.


fmeuser_gc
Contributor
Forum|alt.badge.img+8
  • Author
  • Contributor
  • October 3, 2017
takashi wrote:

I can see two numbers concatenated with a hyphen for each cell in the col A (EVENTIDRAN field).

"737055 - 737060""737061 - 737066", ...
Do you need to get all the individual values from them?
"737055""737060""737061""737066", ...
Yes I need all individual values like 737055, 737056, 737057, 737058, 737059, 737060.

 

 


fmeuser_gc
Contributor
Forum|alt.badge.img+8
  • Author
  • Contributor
  • October 3, 2017
rylanatsafe wrote:

Hi @fmeuser_gc - I feel that there will be more than one solution,.. but here is an example workspace template that you can use or build upon. This workspace will add attributes _valx for each integer in the range defined by EVENTIDRAN.

Edit: This workspace was built with FME 2017.1.1 Build 17650 – if incompatible with your FME, the meat and bones of this workspace is included in the image below!

example-extractvaluefromrange.fmwt

Note: It relies on the values of EVENTIDRAN to always be a range that covers six integers, inclusive.

Thank You but it didn't work for me in 2015.1 version. I've tried using AttributeCreator (in 2015.1) instead of AttributeManager (in 2017v).

 

 


rylanatsafe
Safer
Forum|alt.badge.img+13
  • Safer
  • October 3, 2017
fmeuser_gc wrote:
Thank You but it didn't work for me in 2015.1 version. I've tried using AttributeCreator (in 2015.1) instead of AttributeManager (in 2017v).

 

 

@fmeuser_gc - Attached is a version that will work in 2015.1.3.2 – same basic idea with the AttributeCreator! :)

 

example-extractvaluefromrange-20151.fmwt

 


fmeuser_gc
Contributor
Forum|alt.badge.img+8
  • Author
  • Contributor
  • October 3, 2017
rylanatsafe wrote:

Hi @fmeuser_gc - I feel that there will be more than one solution,.. but here is an example workspace template that you can use or build upon. This workspace will add attributes _valx for each integer in the range defined by EVENTIDRAN.

Edit: This workspace was built with FME 2017.1.1 Build 17650 – if incompatible with your FME, the meat and bones of this workspace is included in the image below!

example-extractvaluefromrange.fmwt

Note: It relies on the values of EVENTIDRAN to always be a range that covers six integers, inclusive.

It still didn't work. I was able to get values as x, x+1, x+2, x+3..

 

 

 


rylanatsafe
Safer
Forum|alt.badge.img+13
  • Safer
  • October 3, 2017
fmeuser_gc wrote:
It still didn't work. I was able to get values as x, x+1, x+2, x+3..

 

 

0684Q00000ArMPNQA3.jpg

 

@fmeuser_gc - What do you have in the AttributeCreator? Does the expression include the "@Evaluate()" function?

 

@Evaluate(@Value(_range{0})+1

fmeuser_gc
Contributor
Forum|alt.badge.img+8
  • Author
  • Contributor
  • October 3, 2017
rylanatsafe wrote:

Hi @fmeuser_gc - I feel that there will be more than one solution,.. but here is an example workspace template that you can use or build upon. This workspace will add attributes _valx for each integer in the range defined by EVENTIDRAN.

Edit: This workspace was built with FME 2017.1.1 Build 17650 – if incompatible with your FME, the meat and bones of this workspace is included in the image below!

example-extractvaluefromrange.fmwt

Note: It relies on the values of EVENTIDRAN to always be a range that covers six integers, inclusive.

Yes it worked now after including the Evaluate fn.

 

But the tricky part is EVENTRANGE is not always a specific set of range. It can be any numbered range and has to be dynamic. Would it be possible to make it dynamic?

 

 

For ex: Range 5-10 and if we define for x, x+1, x+2, x+3. In this case we will end up missing values of 9, 10.

 

 


rylanatsafe
Safer
Forum|alt.badge.img+13
  • Safer
  • October 4, 2017
fmeuser_gc wrote:
Yes it worked now after including the Evaluate fn.

 

But the tricky part is EVENTRANGE is not always a specific set of range. It can be any numbered range and has to be dynamic. Would it be possible to make it dynamic?

 

 

For ex: Range 5-10 and if we define for x, x+1, x+2, x+3. In this case we will end up missing values of 9, 10.

 

 

@fmeuser_gc - Ah, yes.. My example definitely relied on a fixed range size as I had noted. If you need to work with dynamic ranges, hopefully the MINEVENT and MAXEVENT are accurate – because you could then use a loop (e.g. with TestFilter) to count up each iteration from MINEVENT until the value of MAXEVENT is reached. This idea would likely have FeatureMerger in the mix too... To summarize, yes I think it is possible to make it dynamic.

 

 

I suggest that you give it a try – the FME Community will be here to help! You may find it useful to create separate Q&A; postings based on what part of the workflow you need help with.

 


fmeuser_gc
Contributor
Forum|alt.badge.img+8
  • Author
  • Contributor
  • October 6, 2017
rylanatsafe wrote:
@fmeuser_gc - Ah, yes.. My example definitely relied on a fixed range size as I had noted. If you need to work with dynamic ranges, hopefully the MINEVENT and MAXEVENT are accurate – because you could then use a loop (e.g. with TestFilter) to count up each iteration from MINEVENT until the value of MAXEVENT is reached. This idea would likely have FeatureMerger in the mix too... To summarize, yes I think it is possible to make it dynamic.

 

 

I suggest that you give it a try – the FME Community will be here to help! You may find it useful to create separate Q&A; postings based on what part of the workflow you need help with.

 

I have a hard time in getting this loop. Tried using Tester and TestFilter but no luck.

 

 


takashi
Influencer
  • October 7, 2017

If the number of values within a range could be different for each row, the method suggested by @LenaAtSafe can be applied.

Alternatively, the AttributeSplitter + PythonCaller with a small script could also be a solution. For example, assuming that the hyphen-separated range values has been split into _list{0} and _list{1} with the AttributeSplitter beforehand, a PythonCaller with this script stores every value within the range into a list attribute called "_value{}".

# PythonCaller Script Example
def extractRangeValues(feature):
    s = int(feature.getAttribute('_list{0}'))
    t = int(feature.getAttribute('_list{1}'))
    for i, v in enumerate(range(s, t+1)):
        feature.setAttribute('_value{%d}' % i, v)<br>

fmeuser_gc
Contributor
Forum|alt.badge.img+8
  • Author
  • Contributor
  • October 8, 2017
lenaatsafe wrote:

Hi @fmeuser_gc

one more possible approach could be to:

  • create a copy of the original feature for each value in the EVENTIDRAN range;
  • calculate the corresponding range value for each copy;
  • merge all copies into single feature and store all range values as a list.

This will allow you to process ranges that include different number of values.

Hi @LenaAtSafe - This worked. Able to get all ranges of values. Thanks much!

 


fmeuser_gc
Contributor
Forum|alt.badge.img+8
  • Author
  • Contributor
  • October 16, 2017
lenaatsafe wrote:

Hi @fmeuser_gc

one more possible approach could be to:

  • create a copy of the original feature for each value in the EVENTIDRAN range;
  • calculate the corresponding range value for each copy;
  • merge all copies into single feature and store all range values as a list.

This will allow you to process ranges that include different number of values.

Hi @LenaAtSafe, Any idea how to do the otherway, meaning dynamic higher to lower range.

 

 

For ex: To read from 10 to 5 or 19 to 12

 

 

Currently I'm reading from dynamic lower to higher range. Ex: 5 to 10, 12 to 19.

 

 


fmeuser_gc
Contributor
Forum|alt.badge.img+8
  • Author
  • Contributor
  • October 26, 2017
takashi wrote:

I can see two numbers concatenated with a hyphen for each cell in the col A (EVENTIDRAN field).

"737055 - 737060""737061 - 737066", ...
Do you need to get all the individual values from them?
"737055""737060""737061""737066", ...
Hi @takashi, any idea how to do other way around from higher to lower range.

 

For ex; 737060 - 737055 should be exploded as 737055, 737056, 737057, 737058, 737059, 737060

 


takashi
Influencer
  • October 26, 2017
fmeuser_gc wrote:
Hi @takashi, any idea how to do other way around from higher to lower range.

 

For ex; 737060 - 737055 should be exploded as 737055, 737056, 737057, 737058, 737059, 737060

 

If you adopted the solution @LenaAtSafe provided, you can insert a ListSorter between the AttributeSplitter and the Cloner to sort the elements of the list by numeric ascending.

fmeuser_gc
Contributor
Forum|alt.badge.img+8
  • Author
  • Contributor
  • October 31, 2017

@takashi, @LenaAtSafe - I also encountered values with multiple ranges within single field (For ex: 1-5, 6-10 in single field) which causing it to fail.

It was working earlier for only single range values say 1-5 in a single field.

Apologize many questions on this scenario.


takashi
Influencer
  • November 1, 2017
fmeuser_gc wrote:

@takashi, @LenaAtSafe - I also encountered values with multiple ranges within single field (For ex: 1-5, 6-10 in single field) which causing it to fail.

It was working earlier for only single range values say 1-5 in a single field.

Apologize many questions on this scenario.

You can split the comma separated multiple ranges (e.g. "1-5, 6-10") with an AttributeSplitter (Delimiter: ,) and explode the resulting list with a ListExploder. You can then apply @LenaAtSafe's method to individual single range (e.g. "1-5").

 


Reply


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