File reader: read all columns as strings

Hi,

Is there a possibility to read all columns as a string by default, instead of letting the file reader guess the data type?
The only possible solution I know of right now is to change all columns back to string manually, which is rather time consuming if the table has many columns.

Thanks in advance,
David

@schulz_d welcome to the KNIME community

Yes that is possible with the help of R’s readr package.

Assuming Location is the (well) location of the CSV file as a flow variable and it has pipes (|) as separators (you could replace that with whatever separator you use).

library(readr)

file_location <- knime.flow.in[["Location"]]

knime.out <- as.data.frame(read_delim(file=file_location
, delim="|"
, col_names = TRUE
, col_types = cols(.default = "c")))
4 Likes

Many thanks for the workaround.
Would still be nice to have a solution entirely within knime, but this should work out for so long

3 Likes

In my cases it was suitable to use a “File Reader” with a “Cell Splitter” Node afterwards.

If the “Column Delimiter” was set to “none”, the reader creates a table with one string column only. The cell splitter creates multiple columns with the same Data Type.

6 Likes

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