Gdata软件包Perl问题 [英] Gdata package perl issue

查看:443
本文介绍了Gdata软件包Perl问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试按照这个简单的2分钟视频教程,将Excel电子表格作为数据框导入R: http://www.screenr.com/QiN8

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

我遵循了每个步骤,包括在Win 7 PC上下载并安装Strawberry Perl(32位),将R指向我的工作目录,然后在R中输入以下命令:

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")

我收到此错误:

findPerl中的错误(详细=详细): 找不到perl可执行文件.使用perl =参数指定正确的路径. file.exists(tfn)中的错误:无效的文件"参数

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

更新:

我重置机器并将路径设置为Perl:

I reset my machine and set the path to Perl:

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

然后我输入以下命令:

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

命令行返回此错误:

xls2sep中的错误(xls,sheet,verbose = verbose,...,method = method,: 缺少中间文件'C:\ Users \ AEID \ AppData \ Local \ Temp \ RtmpoXMywa \ file18e45ed513c.csv'! 另外:警告消息: 运行命令'"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'的状态为2 file.exists(tfn)中的错误:无效的文件"参数

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

我做错了什么?

提前感谢您的帮助!

AME

推荐答案

使用library(gdata)加载gdata软件包后,它会清楚地显示:

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

gdata:read.xls()将无法读取Excel XLS和XLSX文件 gdata:除非使用'perl ='参数指定位置 gdata:有效的perl解释器.

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.

因此,您需要有效的perl解释器的PATH. 在这种情况下,使用Windows,您需要检查属性以找到所需的perl解释器.

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)

对于多个xls文件:

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

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

如果为verbose = TRUE,则在每个文件的末尾将显示为:

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.

这篇关于Gdata软件包Perl问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆