Skip to main content
Solved

Creating multiple copies of an output


Forum|alt.badge.img
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

Best answer by takashi

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
View original
Did this help you find an answer to your question?
This post is closed to further activity.
It may be a question with a best answer, an implemented idea, or just a post needing no comment.
If you have a follow-up or related question, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

takashi
Influencer
  • Best Answer
  • October 3, 2014
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

Forum|alt.badge.img
  • Author
  • October 6, 2014
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

Forum|alt.badge.img
  • Author
  • October 7, 2014
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. :-/

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