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.
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.
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
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?
No errors at all. And yes that's correct. I'm running the actual workflow, not the interactive one in the configuration.