Skip to main content
Solved

Default value from a xls file into a db


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.

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

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+11
  • 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.


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