Question

File name using attribute with single value


Badge

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

Userlevel 2
Badge +17

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.

Badge

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

Badge +2

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

 

Userlevel 2
Badge +17

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.

Userlevel 2
Badge +17

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.

Badge

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.

Badge +2

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

Badge

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.

Userlevel 2
Badge +17

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:

Badge

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

Reply