Skip to main content
Question

How to read files within a zipped folder?


creinier
Contributor
Forum|alt.badge.img+3

I'm attempting to filter through all the files within a specific location to identify what shapefiles and feature classes exist within that location (dealing with over 500,000 files). I'm using a Directory and File Pathnames reader to kick off the workflow which is recognizing that there are zip folders within the location, but stops at the zipped folder and won't read the files within them.

 

Is there a way for me to read in the files from the zipped folders as well?

 

Thanks!

5 replies

redgeographics
Celebrity
Forum|alt.badge.img+49

You can use the Schema (Any Format) reader to parse the zipfiles and find all shapefiles and feature classes within them. If you're pointing it to a zip make sure to have it read filename.zip\\*.* rather than filename.zip


takashi
Influencer
  • December 5, 2023

I would use a FeatureReader executing the second PATH reader.

Send file paths whose extension is zip to a FeatureReader. In the FeatureReader, set the second PATH reader as Format, and set "@Value(path_unix)/*.*" to the Dataset parameter, as in:

featurereader-paremeters


creinier
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • December 6, 2023
takashi wrote:

I would use a FeatureReader executing the second PATH reader.

Send file paths whose extension is zip to a FeatureReader. In the FeatureReader, set the second PATH reader as Format, and set "@Value(path_unix)/*.*" to the Dataset parameter, as in:

featurereader-paremeters

Thanks for your suggestion! I tried this initially and couldn't get it to work, but revisited it after your comment and it seems to be working now. One thing I noticed though is that the path_windows changes from where the file is actually located to a temporary file location on the C: drive - any ideas why this is changing? I would like to be able to export the file path of the actual file using the path_windows. Thanks again for your help.


creinier
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • December 6, 2023
redgeographics wrote:

You can use the Schema (Any Format) reader to parse the zipfiles and find all shapefiles and feature classes within them. If you're pointing it to a zip make sure to have it read filename.zip\\*.* rather than filename.zip

I gave this a shot and couldn't quite achieve what I was hoping for. Using a FeatureReader transformer and a second PATH reader seems to do the job. Thank you for your suggestion!


redgeographics
Celebrity
Forum|alt.badge.img+49
creinier wrote:

Thanks for your suggestion! I tried this initially and couldn't get it to work, but revisited it after your comment and it seems to be working now. One thing I noticed though is that the path_windows changes from where the file is actually located to a temporary file location on the C: drive - any ideas why this is changing? I would like to be able to export the file path of the actual file using the path_windows. Thanks again for your help.

That's because when FME reads from a zipfile it unzips that to a temporary location first.


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