ArticlesBlog

Data Access in KNIME: File Reader

Data Access in KNIME: File Reader


Any data analytics work requires to read data. So we concentrate here in reading data from a file, in particular from a .csv file. We want to read the content of this file “SentimentRating.csv”. One of the many ways to read a .csv file is to use a File Reader node. So let’s look for the File Reader node. Here it is. Let’s open the configuration window. The configuration window of the File Reader requires the path of the file and a few information pieces about the structure of the file: if it contains column headers, row IDs, what’s the column delimiter, and so on. The “Advanced…” button takes you to a series of more advanced settings to read your file. So let’s find our file. Here it is. The File Reader node is a relatively smart node, which means that it does a fair amount of auto-guessing. Indeed, it has guessed that this file contains the column headers of the data. It has also guessed that this file contains the row ID of the data, which is not correct. So this setting has to be corrected manually. So here, I unset my “read row IDs”, and that’s my new preview of the file. Everything looks correct here. However, if I want to change some more settings, for example in the advanced part, I can click the “Advanced…” button, and then change for example the quotes, the decimal separator, I can ignore spaces, I can even allow rows of different length in the file contents, I can define the missing value pattern, I can define the encoding, I can select only some data rows to be read by the file, and I can require to have unique row IDs. But I don’t need all these settings. In this case the whole preview of the content of the file seems correct, I click “OK”, and my File Reader is now ready to execute its task. Its task is to read the file, so, I right click, select “Execute”, and the File Reader should have read the content of my file. Let’s inspect it. Here, it’s exactly what I expected the File Reader to read. This is not the only way to read a file. For example, going back to my KNIME Explorer, if I select my file and drag and drop it into my workflow editor, the KNIME Analytics Platform automatically associates the File Reader node with the .csv extension of the file. As I said before, this part is not correctly guessed. So I need to fix it manually. Everything else looks correct in the preview now. I select “OK”. And now, after executing the node, I should get the same output.

Comment here