Solved

Question for "HTML" writer output file naming

  • 15 February 2022
  • 9 replies
  • 4 views

Badge

Hello everyone,

 

So I have a workspace, at the end I will output the HTML result by using HTML transformer.

 

For my html report, I would like to have my writer naming: input file name + _level

 

For instance, if the input file is: abc.geojson, the output file is: abc_level.html

 

I tried as the figure below, yet it is not working.

 

Could someone please give me guide on how to make it works.

 

Thank you and sorry for soooooooo many questions recently.

 

Zach

icon

Best answer by chrisatsafe 22 February 2022, 18:06

View original

9 replies

Badge +2

Hi @zacharylee1204​,

Rather than using the published parameter for the source dataset (called $Source_Dataset_GEOJSON_3), you'll want to use the fme_basename format attribute. The fme_basename attribute contains a dataset's filename without the path or extension whereas the source dataset published parameter contains the full path to the source file (i.e. C:\Users\data\example.geojson). In order to use fme_basename, you'll need to expose it either in the reader feature type or using something like an AttributeExposer. 2022-02-15_8-42-42The path for your destination HTML file will look something like this:

.\HTML report\@Value(fme_basename)_Level.html

 

Badge

Hi @zacharylee1204​,

Rather than using the published parameter for the source dataset (called $Source_Dataset_GEOJSON_3), you'll want to use the fme_basename format attribute. The fme_basename attribute contains a dataset's filename without the path or extension whereas the source dataset published parameter contains the full path to the source file (i.e. C:\Users\data\example.geojson). In order to use fme_basename, you'll need to expose it either in the reader feature type or using something like an AttributeExposer. 2022-02-15_8-42-42The path for your destination HTML file will look something like this:

.\HTML report\@Value(fme_basename)_Level.html

 

Hi @chrisatsafe​ , thank you for your prompt response. However, I still have an issue as I tried your steps, as attached below.

 

The html file name is now become @fme_basename_level.html

 

Do I missed any steps in order to make it happen?

 

Thank you!

 

Zach

 

Badge +2

Hi @chrisatsafe​ , thank you for your prompt response. However, I still have an issue as I tried your steps, as attached below.

 

The html file name is now become @fme_basename_level.html

 

Do I missed any steps in order to make it happen?

 

Thank you!

 

Zach

 

My apologies, looks like the value didn't paste in nicely. It needs to be .\\HTML report\\@Value(fme_basename)_Level.html so the writer knows to use the value of that attribute rather than the literal string. I've fixed that in the comment above as well.

 

Sometimes it can be easier to open the text editor from the drop-down menu and double-click on the attribute name so it formats everything for you.

Badge

Hi @chrisatsafe​ , thank you for your prompt response. However, I still have an issue as I tried your steps, as attached below.

 

The html file name is now become @fme_basename_level.html

 

Do I missed any steps in order to make it happen?

 

Thank you!

 

Zach

 

Hi Chris, actually when I open the text editor as you mention, I don't see any "fme_basename" in there.

 

Also, I tried as you said, and it still output as "@Value(fme_basename)_Level.html".

Any advice? ^^"

 

Thank you.

 

Zachary

 

Badge +2

Hi @chrisatsafe​ , thank you for your prompt response. However, I still have an issue as I tried your steps, as attached below.

 

The html file name is now become @fme_basename_level.html

 

Do I missed any steps in order to make it happen?

 

Thank you!

 

Zach

 

The attribute value can be set in the fanout expression:

image

Badge

Hi @chrisatsafe​ , thank you for your prompt response. However, I still have an issue as I tried your steps, as attached below.

 

The html file name is now become @fme_basename_level.html

 

Do I missed any steps in order to make it happen?

 

Thank you!

 

Zach

 

Thanks @chrisatsafe​ and sorry for keep bothering you.

I think the problem is when I go through the transformer HTMLReportGenerator, the "@Value(fme_basename)" will be gone. I tried to use transformers "attributeKeeper and DuplcatFilter", the html file's name can be exported as I wanted.

 

However, I must go through the HTMLreportGenerator, as I have certain data I would like to show. Do you have any solution for this problem?

 

Thank you.

 

Zach

 

Badge

Hi @chrisatsafe​ , thank you for your prompt response. However, I still have an issue as I tried your steps, as attached below.

 

The html file name is now become @fme_basename_level.html

 

Do I missed any steps in order to make it happen?

 

Thank you!

 

Zach

 

This is what I have for the HTMLReportGenerator_5

 

Thank you.

Badge +2

Hi @chrisatsafe​ , thank you for your prompt response. However, I still have an issue as I tried your steps, as attached below.

 

The html file name is now become @fme_basename_level.html

 

Do I missed any steps in order to make it happen?

 

Thank you!

 

Zach

 

Hi @zacharylee1204​ 

Ah yes, sorry I didn't see the HTMLReportGenerator in your first screenshot. There are a few ways you can still use fme_basename. One method is using a VariableSetter and VariableRetriever. The following should work:

 

image 

Another way is using a FeatureMerger to merge the basename attribute onto the output feature of the HTMLReportGenerator (similar to this post).

Badge

Hi @chrisatsafe​ , thank you for your prompt response. However, I still have an issue as I tried your steps, as attached below.

 

The html file name is now become @fme_basename_level.html

 

Do I missed any steps in order to make it happen?

 

Thank you!

 

Zach

 

Got it, thanks a lot for your help, Chris! :)

Reply