[R] Using read.xls

Marc Schwartz marc_schwartz at me.com
Thu May 26 17:09:06 CEST 2011


On May 26, 2011, at 5:09 AM, vioravis wrote:

> I am using read.xls command from the gdata package. I get the following error
> when I try to read a work sheet from an excel sheet. 
> 
> Error in xls2sep(xls, sheet, verbose = verbose, ..., method = method,  : 
>  Intermediate file 'C:\Tmp\RtmpYvLnAu\file7f06650f.csv' missing!
> In addition: Warning message:
> running command '"C:\Apps\Perl\bin\perl.exe" "C:/Program
> Files/R/R-2.13.0/library/gdata/perl/xls2csv.pl" "excelFileName.xls"
> "C:\Tmp\RtmpYvLnAu\file7f06650f.csv" "Test Sheet"' had status 5 
> Error in file.exists(tfn) : invalid 'file' argument
> 
> However, the same command works fine with another excel file stored in the
> same directory. 
> 
> Could you please let me know what is causing this problem??
> 
> Thank you.


It looks like the intermediate CSV file is not being created. read.xls() works by extracting the data from the Excel file worksheet, using a Perl script to dump it to a CSV file and then using read.csv() to get the data into R. It is essentially a reversal of the process that I use in WriteXLS() in the CRAN package of the same name.

For some reason, that intermediate CSV file is not being created, possibly because the worksheet you are referencing does not exist, is corrupted or there is some other conflict. Presumably, it is not a permissions issue, if you can use read.xls() on a different XLS file.

Check the XLS file that you are attempting to use and be sure that you can open it properly and that you are passing the correct worksheet identifier.  Also, as I am thinking about it, I believe that read.xls() is not set up to handle XLSX files, so be sure that this is not the case. If so, you will need to re-save the file to an XLS format file.

HTH,

Marc Schwartz



More information about the R-help mailing list