Hello,
I have a simple CSV file called ship_V6.
I have a simple workflow. CSV reader and Python script
The script fails to print a column it is not able to find it.
I have attached the images.
workflow
I have attached the input file. CSV
ship_V6.csv (3.6 KB)
the reader .csv node configuration
the simple Python script in the node of Python with the error after executing the Python node.
I do not understand what is happening. It is something simple.
I appreciate any help.
Thank you in advance
Regards,
Mary
HansS
December 5, 2023, 4:41pm
2
Hi @Mary_lea welcome to KNIME forum
Where is column L in your data? I only see column1 to column22 in your data.
Gr. Hans
1 Like
@Mary_lea your Python node has a data port configured but you do not provide one:
@Aldemir you can export data from within the Python node as Flow Variables or as a dataframe (from a pandas dataframe). The code would look something like this:
import knime.scripting.io as knio
import numpy as np
import pandas as pd
# bring your string to a Flow Variable
knio.flow_variables['var_txt_cbi'] = txt_cbi
# bring your content to a pandas data frame
output_table = pd.DataFrame({'column_txt_cbi': [txt_cbi]})
# bring the dataframe back to KNIME
knio.output_tables[0] = knio.Table.f…
Import CSV File - KNIME Forum (75783).knwf (124.5 KB)
1 Like
Hello Gr. Hans.
If you download the ship_V6 has 119 columns and L is column 50.
Thank
Regards,
Mary
Hello mlauber 71,
I thank you for all the long workflow and the advice.
But I do not understand why a simple statement like this
import knime.scripting.io as knio
Leer la tabla de entrada
df = knio.input_tables[0].to_pandas()
Imprimir la columna ‘L’
print(df[‘Sales Area’])
It is worked perfectly well with another file
I can not attache the other file because it is not allowed by the size bigger than 4MB and it does not work with ship V_6
And with ship_V6 the same does not work.
I know that more complicated things can be done. But for now, I am interested in this simple script.
Why is not working?
I appreciate any help in this specific matter.
Regards,
Mary
@Mary_lea as I have mentioned. Your Python nodes have a data port (the small black triangle) configured but in the code there is no line that would create this data.
Such an output would look like this assuming df is a pandas dataframe (you might want to check the links provided above)
# bring the dataframe back to KNIME
knio.output_tables[0] = knio.Table.from_pandas(df)
If you do not want any output you can remove this port. Then you would have to take care about the output yourself.
You can read more about how the Python integration works here:
https://docs.knime.com/latest/python_installation_guide/#_introduction
Hello,
I manage to solve the problem
Thank you,
Regards,
Mary
1 Like
system
Closed
March 5, 2024, 6:37pm
8
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.