data reading & converting in python script node.

Hello Community,

I am currently working with data in JSON format and am attempting to convert it into a Python dictionary using a Python Script Node in KNIME. However, I seem to have encountered an issue, and the error message I’m receiving is as follows:

TypeError: the JSON object must be str, bytes, or bytearray, not Series.

I suspect that I might be missing a step or making an error somewhere in the process. Could someone please guide me on how to read JSON data into a Python Script Node and convert it into a Python dictionary?

Any assistance or insights would be greatly appreciated.

Thank you in advance!

Hello @kotlapullareddy

In your code line 5 you are trying to import a JSON to pd.DataFrame object.

I would suggest to use an intermediate ‘JSON to Table’ node; aiming to import a KNIME df into the ‘Python Script’ node.

Then you can use the following code:

import json
import as knio
import pandas as pd

# data in
df_knimedf = knio.input_tables[0].to_pandas()

df_dictionary = df_knimedf.to_dict()


INFO:numexpr.utils:NumExpr defaulting to 8 threads.
<class 'dict'>



This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.