Skip to main content
Question

File name using attribute with single value


Forum|alt.badge.img

I'm very new to FME.... I have an attibute with one single value, and other attributes with multiple values. I want my writter to name my file based on that single value, however when I select this attribute to be my file name, it creates two files (one file with no name containing all other attributes, and the other file named correctly but not containing any data)

 

 

10 replies

takashi
Influencer
  • June 8, 2019

It's hard to find any issue without more specific explanation about your workspace configuration. It would be helpful to understand the situation if you could share the workspace with us.


Forum|alt.badge.img
  • Author
  • June 10, 2019
takashi wrote:

It's hard to find any issue without more specific explanation about your workspace configuration. It would be helpful to understand the situation if you could share the workspace with us.

Workspace attached. I cannot upload my XML file, however, i've uploaded it as a .txt

27781-issue-file.txtXLM to CSV.fmw


pratap
Contributor
Forum|alt.badge.img+11
  • Contributor
  • June 10, 2019

Hi,

I assumed that you don't want the record which have file name and you want same filename to file which is created with name ".csv".

Add in the workbench as shown

Pratap

 


takashi
Influencer
  • June 10, 2019

When you configure Feature Type Fanout, you should set the fanout attribute (NEW_FILE_NAME) having an appropriate destination feature type name (i.e. CSV filename) to every feature.

In you case, just a single feature from <Instrument_info_data_header> element has values in "Project_ID" and "Location", other features from <Log> elements don't have values in those attributes. Therefore, only the "Instrument_info_data_header" feature has been written into the correct file, others have been written into "." file.

A possible workaround is, merge the "NEW_FILE_NAME" having an appropriate value to every "Log" feature before writing.

For example: The FeatureMerger (Join On: 1 to 1) merges NEW_FILE_NAME to every Log feature unconditionally.


takashi
Influencer
  • June 10, 2019
takashi wrote:

When you configure Feature Type Fanout, you should set the fanout attribute (NEW_FILE_NAME) having an appropriate destination feature type name (i.e. CSV filename) to every feature.

In you case, just a single feature from <Instrument_info_data_header> element has values in "Project_ID" and "Location", other features from <Log> elements don't have values in those attributes. Therefore, only the "Instrument_info_data_header" feature has been written into the correct file, others have been written into "." file.

A possible workaround is, merge the "NEW_FILE_NAME" having an appropriate value to every "Log" feature before writing.

For example: The FeatureMerger (Join On: 1 to 1) merges NEW_FILE_NAME to every Log feature unconditionally.

@pratap beats me! The concept of my solution is the same as theirs.


Forum|alt.badge.img
  • Author
  • June 10, 2019

This worked! thank you @takashi and @pratap.

My next hurdle would be to get this to run for multiple input files. I tried changing the intial reader on "feature reader" to the folder containing my files, however it only output's one CSV, and the others don't write out. Alternatively, I've tried creating a batch upload workspace using "workspacerunner", and this does the same thing. See zip file containing both workspaces, folder structure, as well as a few sample read-in files. XLE to CSV.zip

I'm appreciative of any help you can provide. I'm very new to FME, trying to learn things on my own, but get stuck often and i'm finding it hard to try and troubleshoot on my own.


pratap
Contributor
Forum|alt.badge.img+11
  • Contributor
  • June 11, 2019

Hi,

1. Convert the input path in feature reader to published parameter

 

 

2. It is better, if you pass 1 by 1 file instead at once

3. Change the parameter of "wait job to complete" to "Yes"

4. Provide 1 file path in "File" location as shown below

5. You can place all these details in spreadsheet and use the spreadsheet as reader in BATCH UPLOADER - XLE to CSV.fmw such that you can reduce manual intervention between each file


Forum|alt.badge.img
  • Author
  • June 11, 2019
pratap wrote:

Hi,

1. Convert the input path in feature reader to published parameter

 

 

2. It is better, if you pass 1 by 1 file instead at once

3. Change the parameter of "wait job to complete" to "Yes"

4. Provide 1 file path in "File" location as shown below

5. You can place all these details in spreadsheet and use the spreadsheet as reader in BATCH UPLOADER - XLE to CSV.fmw such that you can reduce manual intervention between each file

@pratap were you able to get this to work on your end? It won't run properly if i do not read in the file at once because of encoding issues with the files.


takashi
Influencer
  • June 11, 2019
pratap wrote:

Hi,

1. Convert the input path in feature reader to published parameter

 

 

2. It is better, if you pass 1 by 1 file instead at once

3. Change the parameter of "wait job to complete" to "Yes"

4. Provide 1 file path in "File" location as shown below

5. You can place all these details in spreadsheet and use the spreadsheet as reader in BATCH UPLOADER - XLE to CSV.fmw such that you can reduce manual intervention between each file

Once you have created a published parameter linked to the Dataset parameter of the FeatureReader in the workspace "XLE to CSV.fmw", you can just pass XLE file paths fetched by the PATH reader (i.e. "path_unix" or "path_windows") to the parameter through the WorkspaceRunner, as in:


Forum|alt.badge.img
  • Author
  • June 12, 2019

Thank you @pratap and @takashi. I really appreciate all the help!


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