Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gdata package perl issue

Tags:

r

excel

perl

I am attempting to follow this easy 2-minute video tutorial on importing an Excel spreadsheet into R as a data frame: http://www.screenr.com/QiN8

I followed each step, including downloading and installing Strawberry Perl (32-bit) on my Win 7 PC, pointing R to my working directory, and entering the following command in R:

Spreadsheet <- read.xls("targetspreadsheet.xls")

I receive this error:

Error in findPerl(verbose = verbose) : perl executable not found. Use perl= argument to specify the correct path. Error in file.exists(tfn) : invalid 'file' argument

Update:

I reset my machine and set the path to Perl:

perl <- "C:/strawberry/perl/bin/perl.exe"

Then I entered this command:

DF <- read.xls("spreadsheet.xls", perl = perl)

The command line returned this error:

Error in xls2sep(xls, sheet, verbose = verbose, ..., method = method, : Intermediate file 'C:\Users\AEID\AppData\Local\Temp\RtmpoXMywa\file18e45ed513c.csv' missing! In addition: Warning message: running command '"C:\STRAWB~1\perl\bin\perl.exe" "C:/Users/AEID/Documents/R/win-library/2.15/gdata/perl/xls2csv.pl" "GFT_show_wip_report(42).xls" "C:\Users\AEID\AppData\Local\Temp\RtmpoXMywa\file18e45ed513c.csv" "1"' had status 2 Error in file.exists(tfn) : invalid 'file' argument

What am I doing wrong?

Thanks in advance for your help!

AME

like image 214
AME Avatar asked Jun 07 '12 21:06

AME


4 Answers

After loading the gdata package using library(gdata) it clearly says:

gdata: read.xls() will be unable to read Excel XLS and XLSX files gdata: unless the 'perl=' argument is used to specify the location of a gdata: valid perl intrpreter.

So, you need the PATH to the valid perl interpreter. Using windows, as is the case here, you need to check the properties to locate the required perl interpreter.

#set the PATH to perl interpreter
perl <- "C:/strawberry/perl/bin/perl5.18.2.exe"

try1file <- read.xls("my.one.filename.xls", perl = perl)

For multiple xls files:

> length(list.files())
[1] 65

try65files <- lapply(list.files(), ..., perl = perl) 

If verbose = TRUE, at the end of each file it will read:

Loading 'F65.xls'...
Done.
Orignal Filename: F65.xls
Number of Sheets: 1
Writing sheet number 1 ('Sheet1') to file 'C:\Users\FRANKL~1.JOH\AppData\Local\Temp\RtmpeKs3fi\file13dc750950e4.csv'
Minrow=0 Maxrow=32 Mincol=0 Maxcol=16
  (Ignored 0 blank lines.)
0 
Done.
Reading csv file  “C:\Users\FRANKL~1.JOH\AppData\Local\Temp\RtmpeKs3fi\file13dc750950e4.csv” ...
Done.
like image 55
user2502338 Avatar answered Nov 01 '22 12:11

user2502338


As some other answers say already the problem is that perl.exe is missing. In my case it worked after getting it installed from: http://www.activestate.com/activeperl/downloads and then point to it:

    read.xls("bla.xlsx", perl = "C:\\Perl64\\bin\\perl.exe")
like image 20
Francisco López-Sancho Avatar answered Nov 01 '22 12:11

Francisco López-Sancho


The problem went away after I ran the following script and restarted the PC:

library(gdata)
installXLSXsupport(perl = 'C:\\strawberry\\perl\\bin\\perl.exe')
like image 1
Igor Krupitsky Avatar answered Nov 01 '22 12:11

Igor Krupitsky


I have recently got the same problem with gdata package and Strawberry Perl software under Windows 10. The solution in my case is as follows: (1) uninstall an old version of the Strawberry Perl -- if you try to install new version over the old one, it says that it is not upgradable, (2) install a new version downloaded from this link to C:/Strawberry/, (3) add C:/Strawberry/perl/bin/perl.exe to 'Path' in User variables of the Environment Variables window.

like image 1
Vladimir S. Avatar answered Nov 01 '22 12:11

Vladimir S.