Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Transforming python to output data frame into workflow

Alternator
5 - Atom

I'm using the Python tool with a Python script that queries data and ultimately writes this data to a csv, however I'd like to transform it so that it writes to a Data Frame instead (to be able to pass through into the workflow).

 

What would it take to convert this into a process that creates and builds a Data Frame with the same results? 

 

I've attached the workflow.

 

Thank you.

5 REPLIES 5
BrandonB
Alteryx
Alteryx

Here is the Python tool documentation: https://help.alteryx.com/current/designer/python-tool 

 

Alteryx has a built in Alteryx.write(df, output anchor #) method that takes your data frame and a number for what output anchor you want to write to and then sends the data out. All you need to do is use this to write out the data frame. 

danilang
19 - Altair
19 - Altair

Hi @Alternator 

 

Since you're writing to a csv file line by line, the easiest way to do this is to add something like the following line after you close the file.

Alteryx.write(pd.read_csv('my_data.csv') ,1)

 

This will read the contents of the csv as a dataframe and push it to the #1 output of the Python tool.

 

Dan

Alternator
5 - Atom

Hmm. I'm trying this but nothing is coming through the output (I have a browse and a select coming off of 1). I've tried with that line in a couple different places but still nothing. 

 

This:

cursor.close()
cnxn.close()
except Exception as error:
print(error)

Alteryx.write(pd.read_csv('my_data.csv') ,1)

 

 

and this:

 

cursor.close()
cnxn.close()
Alteryx.write(pd.read_csv('my_data.csv') ,1)
except Exception as error:
print(error)

 

 

Any ideas?

TheOC
15 - Aurora
15 - Aurora

are you getting an error?

And just an a sanity check, are you running the actual workflow, with the python tool in? Not just hitting run within the configuration window of the tool?


Cheers,
TheOC


Bulien
Alternator
5 - Atom

No errors at all. And yes that's correct. I'm running the actual workflow, not the interactive one in the configuration.

Labels