I am reading around 120 spatial tables in FME. I would like to export a spreadsheet or CSV using FME that contains the feature name (table name) and the number of records in that table.
So far, I've tried linking a counter to each feature type and the Statistics Calculator to get the max value for the counter. I then try to write the CSV with only fme_feature_type and max attributes. I'm getting the max value output okay, but the fme_feature_type is not writing to the CSV.
Any ideas? Also, do I need to add a counter to all the tables separately? Or can I connect them all to a counter and then split it up somehow by fme_feature_type?
3 Answers 3
Try a group by in statistics calculator as fme_feature type, you need to expose the fme feature type from the reader.
-
Yes, in which case the "Total Count" output is what will contain your result. But the Counter method is equally as valid.Mark Ireland– Mark Ireland2013年03月04日 16:56:09 +00:00Commented Mar 4, 2013 at 16:56
-
I had actually tried this and it was working but not outputting the fme_feature_type, just the count. I tried exposing the attribute but it wasn't working. In the end, I manually added fme_feature_type as a user attribute and it worked, even though I had already added it in the Format Attributes. It's working now and this was the best approach. Thanks.Fezter– Fezter2013年03月05日 00:30:05 +00:00Commented Mar 5, 2013 at 0:30
Not tried this, but it sounds like you should be able to use the Counter transformer and specify your feature_type_name
(or fme_feature_type
if you haven't renamed it) attribute as the "Counter Name" parameter:
Counter Name
Create separate sequences of numbers to be assigned, either by placing several Counter transformers with each having a different counter name, or by choosing an attribute whose value will be used as the counter name as each feature passes through. (In effect, using an attribute to supply the Counter name is like having a Group By option for the Counter.)
I also found this discussion on FME Community Answers.
-
1Remember to check the default start number 0, sometimes you might want it to start at 1 or -2 etc depending on your workspace.2013年03月01日 14:24:08 +00:00Commented Mar 1, 2013 at 14:24
-
The default attribute is _count you can use the AttributeRenamer to change that after that transformer.2013年03月01日 14:26:27 +00:00Commented Mar 1, 2013 at 14:26
I decided to simply add readers for all the objects I needed a count for and hit run. After it 'runs' the 'Features Read Summary' in the log has all the counts, and I just copied that into a text doc which could easily be converted to a csv.
-
This is fine if you don't have many feature types. However, if you have an unknown number of files. For example, you're reading thousands of shapefiles in a folder and subfolders, this wouldn't work. Even in my example of 120 files, this seems like too many readers.Fezter– Fezter2017年03月01日 23:10:23 +00:00Commented Mar 1, 2017 at 23:10
-
This solution is OK for testing while building a workbench, but doesn't allow for automation.Erica– Erica2019年04月11日 15:57:13 +00:00Commented Apr 11, 2019 at 15:57