Hi,
Maybe this works as expected.
(1) Replace the attribute name "Race" with the feature type name, using a BulkAttributeRenamer.
Rename: Selected Attributes
Selected Attributes: Race
Action: Regular Expression Replace
Text To Find: .+
String: fme_feature_type (attribute that contains feature type name)
(2) Add sequential number attribute with a Counter, grouping by the feature type name.
Count Output Attribute: _count
Counter Name: fme_feature_type (attribute that contains feature type name)
(3) Aggregate the features with an Aggregator, grouping by the count number.
Group By: _count
Mode: Attributes Only
Keep Input Atributes: Yes
(3) Expose the required attribute names (Birds, Dogs, etc.)with an AttributeExposer.
You can then write the result into a CSV file.
If a shape file could contain duplicate "Race" values, consider using the DuplicateRemover at first.
Takashi
Thanks Takashi! Works like a charm.
Is there any chance to get the names automatically in the exposer instead of typing them all in?
If you create an external table (csv or similar) containing list of the attribute names, you can import it into the AttributeExposer with "Import" button > "Import Attribute Values".
Just be aware that the setting is static, it will not change dynamically even if you modify the table. When you need to change the setting, you will have to edit manually, or modify the table and import it again.
As far as I know, there is no way other than typing manually or importing table.
Actualy you can make it l;ess statis and create a csv trough a filewriter. A workspacecaller callin a csv 2 xlsx will take care off the attributes.
I recomend, using Takashi's Aggregation-technique to do following.
Prior to the bulkattribute renamer, create a copy of (in your case) the "race" attribute to "race_copy".
Now in the aggregateor change parameters like this:
Enter a list name.
Concatenate on "race_copy" and "fme_feature_type"
At this stage the csv rows are already there, you just need to create a header and order the rows.
Here is a way to do that
the workspacecaller calls a simple csv2xlsx.
I used ome random files at work here, with a common attribute.
As you can see copnstruction takes more transformers then the aggregationtechnique...
But this way you need not to manualy expose attributes.
Also it is easy to make the attribute of interest a user choice, filled by a startup script or so.
Takashi can show you how to make a attribute extraction start-up python script.
Thank you Gio.
I did it by the numbers. For some reason everything is getting dumped into one column. "Races" first then the "names".
WHen you follow the routine and copy the attribute "race" to "race_copy" (in my case i used "KVK_nummer" Replace this with your attribute "Race")
Like this :
Rest of the script i posted is just formatting and assembling the csv.
After the concatenator it looks like this
in you rcase KVK_copy would be Race_copy, fme_feature_type would hold filenames (the Names).
This then is assembled into a csv.