Dataframe to datatable server exited unexpectedly

What I’m trying to do:
Hi everyone. I am trying to automate a data processing function for a client using Anvil.
What I’ve tried and what’s not working:
I have been using the server module in Anvil to do so. I have been implementing the below code to write the data to a data table which worked in the past, but now throws this error:
Server code exited unexpectedly: 0997ca13dc
The code at the end of the error changes every time. I have included the lines of code that the error seems to originate from. Thanks in advance!

Code Sample:

for d in df_new.to_dict(orient='records'):
    app_tables.my_table.add_row(**d)

Clone link:
share a copy of your app

Welcome to the Anvil Community Forum, er, anvil.

Without seeing the contents of d, this will be very hard to work out!

Since it’s an internal server error, however, Anvil will probably have to get involved.

1 Like

Apologies for the name i know its confusing :sweat_smile:

‘d’ is a dict item that looks like the below:
List like object:
[{column → value}, … , {column → value}]

Before this error i was able to print values of ‘d’ just fine to verify this function works, but the error os preventing me from doing that.

Even if d had a fully-descriptive name, its value might disagree! And that disagreement could be the root of the problem.

You should be able to print it by inserting the print call between the two lines you’ve shown.

d might just contain something unexpected, which may be causing the problem. To determine whether that is, indeed the case, printing d, before it is used, is probably your best bet.

Thank you for the response, unfortunately, still no luck. Same error as before.

My suggestion wasn’t intended to eliminate the error. It was intended to show you how you could print(d), which might illuminate the circumstances of the error.

Yes, I understood the goal, thank you. It just didn’t print anything providing no further detail on why the error occurs. I should have been more clear in my response.

This suggests that the error occurs before the call to print. It might be useful to recheck any assumptions about where the error is occurring.

However, given the nature of the error, it is probably best to email support about it. There is very little that volunteer users like me can do about an internal server error!

Thanks for the input will do so.

I had once too some problems with unexpected exits, while using dict created from pandas to create rows.

In my case the problem was caused by pandas NaN values. I had to replace them with None instead.

I have checked for NaN values and there are none unfortunately. I have emailed support in the meantime.

Did you have to deal with infinities and denormals, too? They can’t be rendered into JSON (for transmittal), either.

Luckily not. It was rendered from excel file so there were only NaNs.

Then I might be inclined to check for other data types (e.g., dates) that are not native to JSON.