Skip to main content

Is there an equivalent reader to the Directory and File Pathnames (DFP) that can take as source parameter a file, or files, including wildcards, and produce one feature for each file, but not actually read in the file.

 

 

Essentially it would be the DFP reader that can take a Filename (Multiple) parameter instead of just a folder.

 

 

My current workaround is to use the Text File Reader, whole file at once, but it's reading a bunch of data unnecessarily.

Can you not do this by using a FeatureReader and using Directory and File Pathnames format? You then have parameters available to use in the Path Filter


Can you not do this by using a FeatureReader and using Directory and File Pathnames format? You then have parameters available to use in the Path Filter

The Directory and File Pathnames format, regardless of whether it is in the FeatureReader or actual reader, will only accept folder names as an input, not filenames.
The Directory and File Pathnames format, regardless of whether it is in the FeatureReader or actual reader, will only accept folder names as an input, not filenames.
I'm maybe misunderstanding the problem, but if you have an input parameter with a filename, you can split this into the folder and the filename, the folder then provides the dataset for the featurereader and the filename can be used a a path filter

 

 


I'm maybe misunderstanding the problem, but if you have an input parameter with a filename, you can split this into the folder and the filename, the folder then provides the dataset for the featurereader and the filename can be used a a path filter

 

 

It may be a filename, it may be multiple filenames, it may have wildcards, or recursions. Basically any option from the filename (multiple) parameter.

 

 

For example, this could be the parameter:

 

""D:\\file1.txt" "D:\\a\\*.txt" "D:\\data\\**\\xyz.txt""

 

 


It may be a filename, it may be multiple filenames, it may have wildcards, or recursions. Basically any option from the filename (multiple) parameter.

 

 

For example, this could be the parameter:

 

""D:\\file1.txt" "D:\\a\\*.txt" "D:\\data\\**\\xyz.txt""

 

 

It appears to handle the wildcards with no issues,

 

e.g. from an input of ""C:\\temp\\file1.txt" "C:\\temp\\a\\*.txt" "C:\\temp\\unknown\\**\\*.txt""

 

It returns

 

C:\\temp\\file1.txt

 

C:\\temp\\a\\file2.txt

 

C:\\temp\\a\\file3.txt

 

C:\\temp\\unknown\\New folder\\file1.txt

 


It appears to handle the wildcards with no issues,

 

e.g. from an input of ""C:\\temp\\file1.txt" "C:\\temp\\a\\*.txt" "C:\\temp\\unknown\\**\\*.txt""

 

It returns

 

C:\\temp\\file1.txt

 

C:\\temp\\a\\file2.txt

 

C:\\temp\\a\\file3.txt

 

C:\\temp\\unknown\\New folder\\file1.txt

 

I assume you split the filename parameter first on the " " beofe the FilenamePartExtractor?

 

 


I used a stringsearcher to get all the matches between quotes then exploded the list before the FilenamePartExtractor, but splitting the parameter would do much the same


I used a stringsearcher to get all the matches between quotes then exploded the list before the FilenamePartExtractor, but splitting the parameter would do much the same

What regex did you use?

 

 


What regex did you use?

 

 

I used "(.*?)" but also made use of the fact that you can manipulate the search in attribute to get rid of the first and last quote marks

 

 


I used "(.*?)" but also made use of the fact that you can manipulate the search in attribute to get rid of the first and last quote marks

 

 

I think the splitter is the better option, as this doesn't match the case where only a single file is present, and there are no quotes.

 

 


I had a similar situation where I was using the Directory and File Pathname (DFP) Reader in a workspace that created a feature and attachments to be added to a GDB. The DFP Reader provided the file metadata and a single record for each file necessary to create the attachment records. I wanted to execute this via email using FME Server which meant that I was no longer going to pass a folder as the parameter, but rather files directly (email attachments).

I used the Data File Reader as a substitute. I exposed the fme_basename and fme_dataset attributes and used an Aggregator Transformer to "Group By" fme_basename giving me a single record. I sub-stringed the extension off of the fme_dataset to create the path _extension, added it to the fme_basename to create the path_filename, and renamed the fme_dataset to become the path_windows.

It worked for my scenario. I write the feature and attachments to an SDE Feature Class used in some Web Apps. No duplication of attachments and they open correctly.

Hope this helps as a suggested solution that can be manipulated to fit your situation.


A path filter string could contain characters which can also be used in a path string, such as square brackets, curly brackets and comma. I therefore think it's hard to automatically split a text string into the two parts - a directory path and a path filter.

If you could an external table having two fields - directory path and path filter to specify the conditions, it could be a workaround to read the table and run the PATH reader via a FeatureReader for each pair of directory and filter. For example:
directoryfilterC:\tmpfolder_ÂA-C]\*.txtC:\tmp\a*.{txt,csv}C:\tmp\unknown**\*.txt

0684Q00000ArKRhQAN.png


 

If you need to specify the pairs of directory and filter as a single parameter, probably you will have to use a special character which won't be used in both a directory path and a path filter as the delimiter between directory and filter. The pipe (|) could be a candidate.


"C:\tmp|folder_hA-C]\*.txt" "C:\tmp\a|*.{txt,csv}" "C:\tmp\unknown|**\*.txt"

Reply