Read SPSS files

Hi, I am trying to read in an SPSS file into knime using the R Source(Table) node.

I am using the code below:

knime.out ← iris # assign your data frame here

library(foreign)
db <-file.choose()
dataset ← read.spss(db, to.data.frame = TRUE)

However I get the following error in the console:

knime.out ← iris # assign your data frame here

  • library(foreign)
  • db <-file.choose()
  • dataset ← read.spss(db, to.data.frame = TRUE)
    **-encoding from UTF-8

Here is a screenshot

Can anyone assist?

Thanks

@andyrgalvin welcome to the KNIME forum.

In this case I do not think the file choose function could work since it would supposedly prompt you to enter a file path and this does not work from within the node.

You would have to enter the path manually or use a string widget node.

knime.out is the data frame that will be read back to KNIME so your imported file will have to be assigned there

knime.out <- dataset

An example how to bring have paths and R in KNIME work together can be found here

(you can download the workflow from the hub)

Then: two more R packages have been suggested to read SPSS files: haven and readspss.

Another note: my SPSS days are in the past but if you experience problems you might want to explore the portable format (if this still is a thing).

1 Like

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