博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
测试各种方法读取xlxs文件
阅读量:5217 次
发布时间:2019-06-14

本文共 1923 字,大约阅读时间需要 6 分钟。

测试各种方法读取xlxs文件

此文参考:

  • Save Excel files into csv file

> # Method 1 transform to csv format

> # Start the clock!

> ptm <- proc.time()

> T2 <- read.csv("weather_data_2012.csv", header = TRUE)

> # Stop the clock

> proc.time() - ptm

user system elapsed

0.06 0.00 0.06

 

  • ODBC

 

Nowadays it still support only 32 bit versions of R and this limit discourage the use of this package. Besides Microsoft Windows and 32-bit R, it requires the Excel ODBC driver installed.

 

  • gdata package

    strawberry-perl is need to be installed in the computer. and peal location should be noted in the code.

> # Method 2

> library(gdata)

> # Start the clock!

> ptm <- proc.time()

> T3 <- read.xls("weather_data_2012.xlsx", sheet = 1, header = TRUE, perl="C:/strawberry/perl/bin/perl.exe")

> # Stop the clock

> proc.time() - ptm

用户 系统 流逝

0.12 0.01 5.86

 

  • xlsReadWrite package

 

xlsReadWrite is reported here for didactically purposes only although it is very fast: it doesn't support .xlsx files and this is not acceptable nowadays.

 

  • XLConnect package

 

XLConnect is a Java-based solution, so it is cross platform and returns satisfactory results. For large data sets it may be very slow.

> library(XLConnect)

> # Start the clock!

> ptm <- proc.time()

> wb <- loadWorkbook("weather_data_2012.xlsx")

> T4 <- readWorksheet(wb, sheet = "Sheet1", header = TRUE)

> # Stop the clock

> proc.time() - ptm

user system elapsed

3.24 0.01 0.81

 

***to use this package xlsx package should be unloaded first.

 

  • xlsx package

 

xlsx package read (and write) .xlsx and .xls files using Java. It is cross platform and uses rJava to deal with Java. Java should be installed in the computer first. This method is very slow.

 

> detach("package:XLConnect", unload=TRUE)

> library(xlsx)

> # Start the clock!

> ptm <- proc.time()

> T1 <- read.xlsx("weather_data_2012.xlsx",1)

> # Stop the clock

> proc.time() - ptm

用户 系统 流逝

50.02 0.02 48.24

转载于:https://www.cnblogs.com/chaseskyline/p/3803919.html

你可能感兴趣的文章
第三章:选择结构(一)
查看>>
缓存(Cache)学习笔记
查看>>
Vue2.0 的漫长学习ing-1-3
查看>>
mount命令(用来挂载硬盘或镜像等)
查看>>
Bash shell中的位置参数$#,$*,$@,$0,$1,$2...及特殊参数$?,$-等的含义
查看>>
Android实现获取系统应用列表(转)
查看>>
5.User Interface/Styles and Themes
查看>>
Scrapy爬虫小demo总结
查看>>
Python基础之---04数据类型
查看>>
Android面试题-兴奋了有木有
查看>>
C#字符串类的典型用法
查看>>
强者运强
查看>>
Spring 梳理 - 构造web项目时,使用eclipse如何引用jar包
查看>>
读《深入理解Elasticsearch》点滴-multi_match
查看>>
外部exe启动UG NX
查看>>
linux base shell 基础语法
查看>>
LeetCode #24 Swap Nodes in Pairs (M)
查看>>
memset函数
查看>>
linux系统目录详解
查看>>
效率 -- 人世间的竞争
查看>>