Skip to main content
Hi All,

 

I have a working workspace which has 4 writers in it (PDF, CSV, CSV, SHP). They currently all write to a single zip file.

 

 

However, what I'd like is for three of the writers to also write a copy of the data to somewhere else (not the zip file).

 

 

Obviously I can just create 3 more writers and plug them in next to the zip-ones, but I was wondering if there was a more elegant solution.

 

 

Notions I've had so far:

 

- Shutdown Python to uncompress/compress stuff. Seems a bit heavy.

 

- A file writer/copier but I'll need a lot of pipework to figure out filenames etc.

 

- 3 new writers.

 

- Add a second directory in the DestDirectory parameter (delimited with a comma). FME errored out.

 

 

Any other notions? Ideally the last one works but I'm doing it wrong.

 

 

Thanks,

 

Jonathan
Hi Jonathan,

 

 

I would add this notion.

 

- Create another workspace with a WorkspaceRunner to run the original workspace twice. i.e. zip-compression mode, and other output mode.

 

 

But I don't think that the Shutdown Python Script approach is so heavy. After getting zip file path and destination folder path from corresponding parameters, this script, for example, decompress the zip and save the extracted files into the specified folder.

 

----

 

if FME_Status == 1:

 

    from zipfile import ZipFile

 

    zip = ZipFile(zip_file_path, 'r')

 

    zip.extractall(destination_folder_path)

 

    zip.close()

 

----

 

The ZipFile module can be imported in standard FME installation.

 

See also here to learn more about the module.

 

ZipFile (https://docs.python.org/2.7/library/zipfile.html#module-zipfile)

 

 

Takashi
Hi Takashi,

 

Thanks. I ended up going down the python route, I prefer your method of extracting from the zip over the one where Python puts them into the zip I think.

 

 

Cheers,

 

Jonathan
Although it turns out - while this works great in FME Desktop, it doesn't work so well in Server. And it's not clear why because FME Server doesn't seem to print anything from Python to the logs. So I know it failed, but not why it failed. 😕

Reply