Skip to main content

Hello,

I have built a workspace in Workbench 2022.2.4 that reads a specified shapefile (e.g. 10_18_24_line_review.shp) from a folder titled C:\New Shapefiles, performs some basic transformations (datetime stamping, attribute formatting, spatial relation, filtering, etc.) writes out two new resulting shapefiles (with naming conventions based on the new ‘_timestamp’ field) to a folder titled C:\Outputs, then moves the original shapefile being read into a C:\Completed folder using the FILECOPY writer.

What I would like to do now is:

Configure the workspace to read in any single zipped shapefile that I place in the “New Shapefiles” folder. Scilicet, the naming conventions of the zipped shapefiles I receive will not be consistently predictable, but only one will be in the “New Shapefiles” folder at a time.

To clarify: my vision is to drag and drop a new zip of a shapefile (containing concomitant files ne.g. .dbf, .prj, .shp, and .shx]) into the empty C:\New Shapefiles folder, open my workspace in Workbench, and hit Run, without needing to Extract All in File Explorer, and without needing to modify my Shapefile Reader/FeatureReader in my workspace every time.

I have tried several things so far, with various combinations of wildcards and Subfolder checkboxes configured in my FeatureReader. I will elide listing them all, but it feels like I am getting close.
 

Thank you in advance!

 

Edited 10/18/24 04:12GMT: qualifying language added

Good Morning,

You may have to use Directory and File Pathname to get the file path first and then connect that to another reader for Esri Shapefiles and supply the path to the dataset.

Please let me know if you encounter any issues!

 

 


I managed to get my desired results with a combination the Directory and File Pathnames reader, paired with a FeatureReader whose dataset is the attribute ‘path_windows’, an AttributeCreator that creates an attribute with the value of my zipped shapefile’s origin folder, and lastly the File Copy writer that uses the aforementioned attribute’s value for its Subfolder Name and performs the File Operation: Move on the Source Parameters.

 

My only issue now is that most of my attribute transformers (NullAttributeMapper, AttributeCreator, and AttributeManager) are showing as ‘Incomplete’ with the red cogs, and seem to indicate that those attributes are not available.

Despite this ostensibly superficial setback, my translation is still 100% successful!

I don’t think this would be the case had I not started with my existing saved workspace that was constructed with a regular shapefile reader (reading the unzipped/extracted shp).

I am likely just a few more steps away from remedying this.


I believe you need to use Attribute Exposer after Shapefile reader. This attribute exposer will be a little tricky if you do not know schema of the shapefile you are receiving. But if it always be the same, just read it once and then you can import from feature cache or specific dataset that matching the shapefile schema. And then click Select All or select only attribute you need. and click import. Then you can connect it to Attribute Creator to send it down stream.

Attribute Manager could completely bypass Attribute Exposer, but you will need to expose the attribute using import from feature cache the first time around.
 


 

 


Good Morning,

You may have to use Directory and File Pathname to get the file path first and then connect that to another reader for Esri Shapefiles and supply the path to the dataset.

Please let me know if you encounter any issues!

 

 

Thank you, I will give this a try!

I jumped the gun and posted my previous reply without refreshing, so I had not seen your helpful reply just yet.


I believe you need to use Attribute Exposer after Shapefile reader. This attribute exposer will be a little tricky if you do not know schema of the shapefile you are receiving. But if it always be the same, just read it once and then you can import from feature cache or specific dataset that matching the shapefile schema. And then click Select All or select only attribute you need. and click import. Then you can connect it to Attribute Creator to send it down stream.

Attribute Manager could completely bypass Attribute Exposer, but you will need to expose the attribute using import from feature cache the first time around.
 

Thank you! This was the last piece I needed!

I attached a new Attribute Exposer (Let’s distinguish, and call it AX1) to the very first shapefile reader I was working with (Let’s call it SR1) in my original workspace, used the Import > From Dataset to navigate to that zip, used the Attribute Names Import Mode, toggled Select All, and hit Import.

 

 

I then navigated back into the Parameters of that same AttributeExposer (AX1), highlighted all of the rows, and Copied them.

 

I pasted these rows into another AttributeExposer (AX2) which was attached directly to the <Generic> port on my FeatureReader, and all of my red cogs resolved. Then I safely deleted both that shapefile reader (SR1), and that AttributeExposer (AX1).


Adding this addendum for posterity:

I was able to produce the same successful results by replacing the Directory and File Pathnames Reader with just a Creator. I also configured the subsequent FeatureReader a little differently (see Dataset) :
 

A lot is achievable for my purposes with the asterisk. The same goes for grabbing shapefiles that are not zipped, but reside alone in an eponymous folder within the target folder, as in this example from a different workspace of mine:

 


Reply