Skip to main content
Question

Removing empty shape file entries based on grouping


Forum|alt.badge.img

Hi there,

I'm having some trouble with performing conditional checks on some shape files I have. Basically, this is what my input looks like:

CityDistrictAA1A2BC

 

C1DE

What I want do do is exclude Cities with blank districts IF they have entries where District is present, but Cities that only have one blank entry should be kept. In this case, I want to keep A1; A2; Bblank; C1; Dblank; and Eblank, whilst removing Ablank and Cblank.

I tried toying with using a tester an making it a composite test, but I have no idea how to use the correct expression.

Thanks in advance,

Robbie

6 replies

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • April 11, 2017

Hi @robbie_botha, a possible way is: if the number of rows belonging to the same city is only one, preserve the feature regardless of its district value, otherwise, preserve the feature only if its district is not empty. To be more specific:

  1. StatisticsCalculator: Count the number of rows belonging to the same city and add the number to corresponding features.
  2. Tester: Filter the features coming from the Complete port of the StatisticsCalculator according to the condition mentioned above.

Forum|alt.badge.img

Hi @takashi,

I don't know if I'm misunderstanding what you're saying, but the problem I have with this solution is that even if I test to preserve all cities with only one entry, how do I specify that cities with multiple entries needs a single specific entry removed? The one that's blank in this case.

Regards,


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • April 11, 2017
robbie_botha wrote:

Hi @takashi,

I don't know if I'm misunderstanding what you're saying, but the problem I have with this solution is that even if I test to preserve all cities with only one entry, how do I specify that cities with multiple entries needs a single specific entry removed? The one that's blank in this case.

Regards,

You should be able to set up a composite test

 

District is empty and _count >1 will route all features to be removed to the passed port for instance

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • April 11, 2017

listbuild or aggregator grouped by City.

Test for listelementcount >1 (or count attribute >1)

On count>1 exploder and filter out empty cells. Keep the rest.


takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • April 11, 2017
robbie_botha wrote:

Hi @takashi,

I don't know if I'm misunderstanding what you're saying, but the problem I have with this solution is that even if I test to preserve all cities with only one entry, how do I specify that cities with multiple entries needs a single specific entry removed? The one that's blank in this case.

Regards,

This is it.

 

 

 


Forum|alt.badge.img

Thanks @takashi, your solution works perfectly!


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