Skip to main content
Question

How read Excel data with dynamic schema (sheet name and attributes)?

  • December 11, 2020
  • 3 replies
  • 661 views

aaron
Contributor
Forum|alt.badge.img+12

I am reading an Excel file online where the sheet name and attribute names sometimes change. I therefore need to read the sheet and attribute names dynamically. I can get the schema but I haven't figured out how to read in the data using a dynamic schema. ("Scan Schema in Dynamic Workflow" doesn't appear to work for the Excel Reader.) I figured out how to use a FeatureReader to get the sheet name dynamically using fme_feature_type_name and then pass it to a second Feature Reader but I haven't figured out how to get the attribute names dynamically and then pass them along to the second FeatureReader so I can read in the data. Or is there another way?

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

germang
Contributor
Forum|alt.badge.img+13
  • Contributor
  • December 29, 2020

Hello @aaron​ ,

You may need to use a Schema reader to read the sheet names and then a FeatureReader to read all the features in all the sheets. They will be output in a single (Generic) port though.

You need to expose the fme_feature_type attribute in the FeatureReader and then use it to separate records from different sheets in the writer.

I attached a sample workspace you may inspire from.


aaron
Contributor
Forum|alt.badge.img+12
  • Author
  • Contributor
  • December 31, 2020

Hello @aaron​ ,

You may need to use a Schema reader to read the sheet names and then a FeatureReader to read all the features in all the sheets. They will be output in a single (Generic) port though.

You need to expose the fme_feature_type attribute in the FeatureReader and then use it to separate records from different sheets in the writer.

I attached a sample workspace you may inspire from.

Hi @germang, thanks for the example workspace. It dynamically exposes the sheet name, which I need, but I also need to dynamically expose the attribute names from the Excel spreadsheet so I can read in the data and then do some processing before creating output. I don't know what the attribute names will be called ahead of time. It's my experience that attribute names have to be exposed beforehand in the Generic port in the FeatureReader. I don't see how to read them in dynamically.

 

I can get the attribute names from the Schema port but I don't know how to pass them into a parameter which could then be read by a second Feature Reader. Do you have an idea how that might work?


germang
Contributor
Forum|alt.badge.img+13
  • Contributor
  • January 1, 2021

Hi,

Attribute names can be obtained in the Schema port or in the Schema reader as you mentioned, unfortunately, I don't know a way to expose those dynamically in an Excel reader.