How to conect Knime with data frame from Python pandas

I used the node Python source to run the sap script and create a data frame in the end. I don’t know the node to transform the out-put table.
Here is the code in Python using the Python Source:
image

I tried the Row filter but is bad.
image

See the result:
image

Hi @Aldemir ,
could you please upload a test file with some lines of your csv source?

1 Like

Yes, please upload a source file so we can see the issue. When making data, the output is as expected on my end:

import pandas as pd
d = {‘col1’: [1, 2], ‘col2’: [3, 4]}
output_table = pd.DataFrame(data=d)

Screen Shot 2022-03-17 at 1.10.23 PM
Screen Shot 2022-03-17 at 1.10.32 PM

1 Like

same result here reading a tab separated file
btw, @Aldemir, looks like your code is a bit redundant. These lines are sufficient to do the job

import pandas as pd
path = "C:/Users/dustb/Dati/input/knime/revised_dataset.tsv"
output_table = pd.read_csv(path, sep="\t")

result:

Sorry friends for don’t reply your help. I was on vacation and it was impossible to think in Knime haha.
I solved the problem using another way to export the data from SAP and I used the following code:
data = pd.read_csv(caminho, sep=’\t’, skiprows=3, encoding=‘latin1’, low_memory=False)
The encoding=‘latin1’ made difference. I’m a beginner in Python and enjoying this combination of Python with Knime. I ran SAP script using Python into Knime and transformed data and exported it to Excel. I could have done everything using Python but I enjoyed Knime and it works very well.
Thank you all.

@Aldemir maybe you want to check out these examples about KNIME and Python to see how they might interact

1 Like

Thank you. I’m enjoying to use Python into Knime. It works very well!!

2 Likes