Skip to main content
Solved

Always create excel file even if data is empty


apence231
Contributor
Forum|alt.badge.img+7

I'm creating a new excel file nightly and some nights there will be no data to populate the excel file, but I need the file to be created anyways. Is there a step in the Excel writer that I'm missing to do this?

Best answer by erik_jan

FME will create a file when the first feature is written. So when no features are written, no file will be created. I see two ways of bypassing this issue:

- Always create an empty record by writing a feature with no values (but that leave you with a XLS file with an empty line, even if data is written).

- Use the option not to write Filed Names first and create (using Creator and AttributeCreator) a feature with the field names as the first feature to write. That will create the file using the field names as first line.

Hope this is useful.

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

6 replies

erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • Best Answer
  • May 16, 2016

FME will create a file when the first feature is written. So when no features are written, no file will be created. I see two ways of bypassing this issue:

- Always create an empty record by writing a feature with no values (but that leave you with a XLS file with an empty line, even if data is written).

- Use the option not to write Filed Names first and create (using Creator and AttributeCreator) a feature with the field names as the first feature to write. That will create the file using the field names as first line.

Hope this is useful.


apence231
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • May 16, 2016
erik_jan wrote:

FME will create a file when the first feature is written. So when no features are written, no file will be created. I see two ways of bypassing this issue:

- Always create an empty record by writing a feature with no values (but that leave you with a XLS file with an empty line, even if data is written).

- Use the option not to write Filed Names first and create (using Creator and AttributeCreator) a feature with the field names as the first feature to write. That will create the file using the field names as first line.

Hope this is useful.

This answer helped me in the right direction! All I did is only add the Creator transformer (and not the attributeCreator) and that is enough for the excel file to create at least the column headers if there is no data. Thanks!


erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • May 16, 2016
apence231 wrote:

This answer helped me in the right direction! All I did is only add the Creator transformer (and not the attributeCreator) and that is enough for the excel file to create at least the column headers if there is no data. Thanks!

And if you set the Creator to create the feature at the end (setting of Creator) the empty line will be the last to write and not be visible even if you have data to write.


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • May 16, 2016
erik_jan wrote:

And if you set the Creator to create the feature at the end (setting of Creator) the empty line will be the last to write and not be visible even if you have data to write.

Or use a NoFeatureTester just prior to the writer.


apence231
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • May 24, 2016
jdh wrote:

Or use a NoFeatureTester just prior to the writer.

The NoFeatureTester tool is awesome! Thanks for the heads up on this tool, I actually updated the workbench with this one because it for sure keeps the column headers when there is no data and it works like a charm.


sujitbhunia
Contributor
Forum|alt.badge.img+1
  • Contributor
  • June 12, 2024

Yes, NoFeature Tester tools working fine.


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