This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
Customize & extend the power of Alteryx. SDKs, APIs, custom tools, and more!
It's the most wonderful time of the year - Santalytics 2020 is here! This year, Santa's workshop needs the help of the Alteryx Community to help get back on track, so head over to the Group Hub for all the info to get started!
I saw this post in the Alteryx Designer Discussions, and although Alteryx does support Unicode encoding by default, it does not have a native way of translating other encodings into Unicode. This got me wondering if there might be a way to leverage the Python SDK for this task. I was able to modify the Python Single Input Output Example Tool to accomplish this task. The core of the code is a function that translates hexadecimal to Unicode.
This function was working really well when ran in an IDE, but was failing to execute the translation in the Python SDK Tool. It turned out this was because of the way values are passed through the Alteryx Engine to Python. The Python SDK uses UTF-8, and the input values are passed in from the engine as strings. This required that I convert the strings to bytes before passing them into the translation function, in order for the function to work properly.
bts = bytes(text, 'utf-8').decode("unicode_escape")
result = unicodeTrans(bts)
This is a pretty simple tool, but I had a lot of fun with this exercise learning more about the Python SDK!