Alteryx Designer Discussions

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

Python Tool throws RuntimeError on Alteryx.read() if there are no rows

braggis
6 - Meteoroid

The Python Tool is throwing a RuntimeError if a input table to the Alteryx.read() function contains no rows.

 

The error shown is:

Error: unable to read input table "4460abb7be83bae8f01b9bf1238a923c" (C:\Users\...

 

I've created a workaround by inputting the column names separately, catching the error, and exporting an empty Pandas DataFrame, but the Alteryx.read() function should handle tables with no rows by creating an empty Pandas DataFrame directly.

 

The implementation is part of a Macro and I can't guarantee they will always be rows received.

 

Had anyone else encountered this problem?

2 REPLIES 2
WilliamR
Alteryx
Alteryx

Hello @braggis ,

I experience an error when no data is passed to the python tool.

As another workaround, you can add a record count with the RecordCount tool with an AppendField to be sure that you push every time a data frame with values inside.

 

(If this post helps, then please consider Accept it as the solution to help the other members find it more quickly).

 

 

SeanAdams
17 - Castor
17 - Castor

Hi @WilliamR 

 

cc: @BlytheE 

 

I battled with this exact error today too!

 

Is there a fix on the roadmap for this?   It seems like the desired behavior would be for the Alteryx.Read to return a dataframe with columns but no rows rather than throwing an error that cannot be managed?

 

it is possible to put the Alteryx.read('#1') into a try-except block - but if it throws an error you just don't know if the error was caused by a missing connection; a failure of the Alteryx library or an empty record-set (which should not be a terminal error condition)!    Doesn't make sense for every user to have to work around this by putting a count tool in front of every python tool just to make sure it doesn't fail because of an empty recordset coming into the input.

 

If it helps - I'm happy to log an idea for this?

 

Thanks @WilliamR 

Sean

 

Labels