I am using read.xls() from the gdata package to read Excel workbooks where each workbook has one sheet. The read fails with the following error.
> read.xls(list.files[[1]])
Error in read.table(file = file, header = header, sep = sep, quote = quote, :
no lines available in input
I can’t figure out the error. sheetCount() returns the following error.
> sheetCount(list.files[[1]])
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
line 161 did not have 13 elements
But this is odd, because the workbook has 27 columns. And nothing seems out of the ordinary for rows 161+/-1 or columns 13+/-1.
Throughout the workbook repeated entries are blank and you’re expected to manually extend them down (which is impractical for the 750+ workbooks that I would like to read).
I tried manually setting quote='' and quote='\'', but these don’t change the output. Is my problem that read.xls() sees some rows as ragged but not others? Any pointers? (I tried the xlsReadWrite package, but I am on 64bit Win 7 and it only works on 32bit systems).
Thanks!
Update
I followed @G. Grothendieck’s suggestions and get the following.
> k <- count.fields(xls2csv(list.xls[[1]]), sep = ","); k
NULL
> L <- readLines(xls2csv(list.xls[[1]])); L
character(0)
The temp file that xls2csv() generates is empty, so now I can’t figure out why my countSheets() call returns the “line 161, column 13” error.
I also followed @Joran’s suggestions and converted the .xls file to a .csv file in Libre Office and it converts and reads just fine (i.e., it counts 27 fields in all 236 lines and logical readLines() output).
Update 2
I should add that I think that these .xls files are not generated by Excel (my source is a little secretive about their origin), but I don’t get any errors or warnings when I open them in Libre Office.
Try this and see if it suggests anything: