Skip to main content
Solved

Name File automatic

  • September 25, 2024
  • 3 replies
  • 50 views

fakimochere
Participant
Forum|alt.badge.img+2

Hello FME Community,

In order to retrieve the list of fields from Shapefiles, I am currently using the following workflow: SchemaScanner => ListExploder => AttributeManager(Name).csv.

My objective is to perform this process on a set of Shapefiles contained in a folder and output the CSV files into another folder while keeping their original filenames.

However, I encountered some issues with this setup:

  1. Filename Issues: I am having trouble preserving the original filename for each output CSV file. The current workflow doesn't seem to carry over the original Shapefile name correctly.
  2. AttributeManager: I'm using AttributeManager to manage field names, but I'm unsure if I'm configuring it correctly for this task. It doesn't seem to handle the filename dynamically.

Do you have any suggestions or solutions to address these issues?

 

Best answer by bwn

 To simplify your workspace, you don’t need individual Readers for each SHP file, and you don’t need SchemaScanner either.

A FeatureReader for SHP, set to read “Schema Only”, and set to read an entire Folder, will in a single Transformer, give the Schemas for all SHP files which will contain all Fields in those Shape files.

For example, this FeatureReader reads the File Names and Fields for all 30 SHP files currently in my C:\Temp Folder.

 

 



This can then be directed to a single CSV Writer and use Fanout to make it write 1 CSV per 1 SHP file Schema

 



Writer Settings



Writer Parameters

 

Sample of 4 of 30 CSV Files Written
 



 

 

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

3 replies

nielsgerrits
VIP
Forum|alt.badge.img+55

I use a FeatureReader with the type Directory and File Pathnames to scan for files. This is probably easier than the route you use. I use a Creator transformer to initiate the FeatureReader.

The FilenamePartExtractor is another transformer which might be handy with this kind of work.


bwn
Evangelist
Forum|alt.badge.img+26
  • Evangelist
  • Best Answer
  • September 25, 2024

 To simplify your workspace, you don’t need individual Readers for each SHP file, and you don’t need SchemaScanner either.

A FeatureReader for SHP, set to read “Schema Only”, and set to read an entire Folder, will in a single Transformer, give the Schemas for all SHP files which will contain all Fields in those Shape files.

For example, this FeatureReader reads the File Names and Fields for all 30 SHP files currently in my C:\Temp Folder.

 

 



This can then be directed to a single CSV Writer and use Fanout to make it write 1 CSV per 1 SHP file Schema

 



Writer Settings



Writer Parameters

 

Sample of 4 of 30 CSV Files Written
 



 

 


fakimochere
Participant
Forum|alt.badge.img+2
  • Author
  • Participant
  • September 25, 2024

It works!

Thank you very much for your responses and for your 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