Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Python Tool Output NUL Character

tmkwil
5 - Atom

I have an Alteryx workflow that uses the Python tool to decrypt a file (using pgpy).  This workflow has worked fine for data files like csv or plain text files, but today I tried decrypting a zip file and there are issues getting the data out of the Python tool.

 

First, the things that work.  The actual work in the Python code is working.  I can read in the encrypted zip file, use my decryption key/certificate with passphrase to decrypt the file into a string.  I then take that string and add it to an empty array to I can build the DataFrame.

 

Another aspect that works is writing normal data files. The data records are written to the DataFrame and are output on the '1' anchor as expected.

 

What doesn't work is when the file being decrypted is a zip (can probably be generalized to binary) file.  The DataFrame inside the Python/Jupyter Notebook contains all the characters, but the data coming out of anchor '1' is cut off after only a few characters.  I expect ~22 MB of data and only 19 bytes are output.  The expected leading 'PK' and 3 unprintable characters.

tmkwil_2-1607455452399.png

 

I know the DataFrame contains all the data by inspecting it in Python (first 35 characters shown here):

tmkwil_1-1607455426644.png

 

 

When I decrypt the file with Kleopatra and look at the .zip file in Notepad++ I see the leading 'PK', 3 normal unprintable characters, then 3 NUL characters, followed by the rest of the data stream.  This matches what the DataFrame contains.

tmkwil_3-1607455634209.png

 

 

I believe the error has to do with Alteryx's handling of the NUL character in the output stream.  As if the tools sees the NUL and assumes that is the end of the stream and cuts it off.

 

1) This seems to be a bug in Alteryx (I'm using 2019.3.6.20285 right now).

2) Does anyone have creative workarounds for getting data with NUL characters out of the Python tool?

 

 

1 REPLY 1
tmkwil
5 - Atom

I have developed a workaround that improves the overall process I have for decrypting files.

 

Instead of sending the data to the Python tool's output anchor I have Python write the file directly to the file system.  This means I no longer have to detect the encoding (utf-8, cp1252, etc) before converting the byte-array into a string.

 

The Python code now just outputs the filename the file was decrypted so and downstream processes can take that and do whatever they need to.

 

I still think it is a bug that NUL characters can't be output, but this workaround is fine with me.

Labels