Unable to read .xls file in R


#1

Hi All,
i downloaded a file from UCI repository.(below link)
https://archive.ics.uci.edu/ml/machine-learning-databases/00350/

I am unable to import it in R
I tried ," read.table" , “read.xlsx” , but was unable to read it.
I got following warning “incomplete final line found by readTableHeader”

I tried googling this error a lot , but was unable to find a solution which would help me read this file successfully in R.
Please help


#2

@Rishabh0709, I can load the file just fine using the code below:

library(xlsx)
data <- read.xlsx('default of credit card clients.xls',
                  sheetName = 'Data', startRow = 2)

However, I think it’s better to open the file in a spreadsheet software and export it to CSV, since read.xlsx() is very slow. Then you can just use read.csv() or fread() from the data.table package as usual.


#3

thanks @caiotaniguchi :slight_smile:


#4

The readxl package makes it easy to get data out of Excel and into R. Compared to many of the existing packages (e.g. gdata, xlsx, xlsReadWrite) readxl has no external dependencies, so it’s easy to install and use on all operating systems.

library(readxl)
data<-read_excel("default of credit card clients.xls", sheet = "Data",skip = 1)