Skip to main content
Solved

Default value from a xls file into a db

  • July 12, 2016
  • 4 replies
  • 24 views

Forum|alt.badge.img

I read an excel file. I extract the value of each cells and put it in my database via a writer. But sometimes, there is no value in the cell.

So I have another excel file to map each cell with a default value. But I cannot manage to actually map it.

Is there a transformer for doing it?

Or Do I have to extract the data from the second xls file into a dictionnary in my workspace to use it?

Thanks.

Best answer by slerendu

Thanks all of you for your answer. Indeed there are a lot of ways to do the same thing.

A colleague of mine find an appropriate solution for my workspace.

First an AttributeExploder to obtain the cells value of the first xls file. Then a StringConcatenator to give a name/reference for each cell (with a value). Next a Joiner to match the cells reference into the mapping xls file. This file contain the default value.

Finally I just have to check if there is no value in the first cell and there is a default value. At last, an AttributeCreator to put the right value in the attribute.

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.

4 replies

david_r
Celebrity
  • July 12, 2016

You could use an AttributeExploder to iterate over all the attribute names, then use a FeatureMerger to get each default value per attribute, then a NullAttributeMapper to substitute empty or missing attributes with the default.


pratap
Contributor
Forum|alt.badge.img+12
  • Contributor
  • July 12, 2016

Hi,

If the default value is null then use as @david_r suggested else if you want some default value when data is not present use AttributeCreator when If Attribute is Missing, Null, or Empty (see the link below for details)

http://docs.safe.com/fme/2016.1/html/FME_Desktop_D...


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • July 12, 2016

Another way to map cells from one to another sheet.

Expose xlxs_row_id.

Then explode the attributes. Remove excess attribute (regex fme* out of the set)

Columnname and row_id can be used to map the values.

Test for the empty cells.

Then use 2 feature mergers to merge them to the mappingcells.


Forum|alt.badge.img
  • Author
  • Best Answer
  • July 13, 2016

Thanks all of you for your answer. Indeed there are a lot of ways to do the same thing.

A colleague of mine find an appropriate solution for my workspace.

First an AttributeExploder to obtain the cells value of the first xls file. Then a StringConcatenator to give a name/reference for each cell (with a value). Next a Joiner to match the cells reference into the mapping xls file. This file contain the default value.

Finally I just have to check if there is no value in the first cell and there is a default value. At last, an AttributeCreator to put the right value in the attribute.