How to import a CSV to KNIME in command line

I want to import a CSV file to KNIME in command line. When I run a command line like this:

"C:\Program Files\KNIME\knime.exe" c:\temp\foo.csv

A dialog pops up, but the button is grayed, I can’t click finish. I’m new to KNIME, just installed it, does KNIME support importing CSV directly? Thanks.

Just got that that’s the way how I import a WORKFLOW, not a CSV file. Then my question is: how do we import a CSV file to my default workspace?

The reason why I want to do this way is: I plan to integrate KNIME with a web tool. On the web, I’ll create a link like this: foobar://knime/test.csv. When user clicks the link, a tool(developed by c++) will invoke KNIME and pass test.csv to KNIME as a parameter, then import the CSV automatically, that’s my purpose.

Hi!

Maybe create a workflow that does what you need?

Br,
Ivan

Thanks, I’ll check this and, other than creating a workflow, is there a simple way to do that?

Not sure but I believe a workflow should be simple but again there is maybe even a simpler solution.
Good luck,
Ivan

Hi @ZhenYu
creating a workflow programmatically should not be too hard, you could try doing the following:

  1. Create a workflow in KNIME, e.g. one that just contains a configured File Reader or CSV Reader node and export it, this is your template that you will use whenever you want to create a workflow.
  2. Unpack the exported workflow and take a look at the settings.xml file in the folder that corresponds to the file reading node. You should be able to locate the entry tag that contains the path to the csv file and set that programmatically in your tool to the path to the csv file you want read by KNIME.
  3. Zip up the workflow again and change the extension to .knwf. Now you can invoke KNIME with the workflow file as an argument.

best,
Gabriel

1 Like

Thanks, I’ll give it a try.