cancel
Showing results for 
Search instead for 
Did you mean: 

Access file in Python script

ash42
New Contributor III

Is it possible to access files written in project space path through python script.
If yes can any one share an example

5 REPLIES 5

bojanvelevski
Valued Contributor

Hi @ash42,

You can read the file with a File reader, and pass the content to the script.
Here’s the piece of code that I’ve been using to import a zip file into the script. It might not be of an immense help, but it can help you to get some pointers at least:

inDoc = self.input.next()
content = inDoc.get('content')
files = zipfile.ZipFile(io.BytesIO(content))

Regards,
Bojan

ash42
New Contributor III

Hi Thanks for response
Basically my requirement is to move or wrtite the file to a ftp server as the the file writer snap is taking too long to write to ftp server ,so i was trying to find a way if we can directly move the file written in project path to a ftp location through script

MattB
New Contributor II

Hi @ash42,

I’ve not found a way to read from the Snaplogic project folder itself but if you have a groundplex you can write to a folder of your choosing using a binary file writer and the path

file:////

Once done you can pick them up using the method suggested by @bojanvelevski.

I did something similar but now pass the raw binary data into the Python script snap (use case is unzip and rotate images), it is more involved but might also save you the io of a additional disk write. Happy to share if you’re interested.

Matt.

ash42
New Contributor III

sure ,please share the sample…