FME Version
Files
Introduction
In FME Workbench, you can write datasets directly into a zip file by simply adding a .zip extension to the output path. For example, the below MapInfoTAB writer will output data to “output.zip”.
Sometimes, you might want to add additional supporting files into an output zip folder, such as metadata, license agreements, and other files or directories. This article demonstrates how to add extra files to a zip output using a File Copy Writer.
Step-by-Step Instructions
The attached workspace, ZipFile_Start.fmwt, performs a simple translation from MapInfo TAB to MapInfo TAB, with the output set to “output.zip”. Follow the steps below to add extra supporting files to the zip file.
1. Open ZipFile_Start.fmwt in FME Workbench
Download the tutorial attachments and open ZipFile_Start.fmwt in FME Workbench. The workspace is set up to convert the city_parks dataset to a MapInfo TAB zip file.
2. Add a Directory and File Pathnames Reader
A Directory and File Pathnames Reader can be used to get the additional supporting files. Add one to the workspace and set the Dataset parameter to the extra file(s) you would like to include. In this scenario, we want to include the files in the “SpecialFiles” folder from the tutorial download.
Click OK. The workspace should look like this.
3. Add a File Copy Writer
Add a File Copy Writer to the workspace. Leave the “Dataset” parameter blank. Set the “Subfolder Definition” parameter to “Automatic”.
Click OK. In the Feature Type dialog, set the subfolder name to “extrafiles”.
Click OK. Connect the PATH feature type to the extrafiles feature type
4. Connect attributes
Expand the “PATH” and “extrafiles” feature types. Connect the path_unix (Mac) or path_windows (Windows) attribute to the filecopy_source_dataset attribute.
Now the workspace is ready to read the additional supporting files and write them to the extrafiles output folder using the File Copy Writer. Next, we need to configure the path to write to.
5. Link the File Copy destination path to the main writer path
In the Navigator pane, expand the FILECOPY writer, then right-click the “Destination File Copy Folder” parameter.
Click “Link to User Parameter”.
In the drop-down menu, choose “DestDataset_MITAB”. This will link the destination path for the File Copy Writer to the MapInfo zip file output.
Click OK. The workspace is now configured to write the extra files to the same path as the MITAB writer.
6. Run the workspace
Run the workspace, and view the output in your file browser. You will see a file called “output.zip”, which contains an extrafiles folder with the two additional supporting files.
Alternative Methods
Rather than getting the additional supporting files using the Directory and File Pathnames Reader, you could use the StringConcatenator to build the string(s) to the file paths. However you retrieve the files, the important things are to:
- set the filecopy_source_dataset attribute to the path of the extra files, and
- link the File Copy Writer’s destination path to the workspace’s main writer.
Data Attribution
The data used here originates from data made available by the Government of Austin, Texas. It contains information available to the public domain.
Comments
0 comments
Please sign in to leave a comment.