r-gregmisc-users Mailing List for R gregmisc package (Page 25)
Brought to you by:
warnes
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
(12) |
Apr
(5) |
May
(3) |
Jun
(5) |
Jul
(2) |
Aug
(5) |
Sep
(7) |
Oct
(15) |
Nov
(34) |
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(3) |
Feb
(16) |
Mar
(28) |
Apr
(5) |
May
|
Jun
(5) |
Jul
(9) |
Aug
(50) |
Sep
(29) |
Oct
(9) |
Nov
(25) |
Dec
(7) |
2008 |
Jan
(6) |
Feb
(4) |
Mar
(5) |
Apr
(8) |
May
(26) |
Jun
(11) |
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(9) |
2009 |
Jan
|
Feb
(1) |
Mar
|
Apr
(2) |
May
(26) |
Jun
|
Jul
(10) |
Aug
(6) |
Sep
|
Oct
(7) |
Nov
(3) |
Dec
(2) |
2010 |
Jan
(45) |
Feb
(11) |
Mar
|
Apr
(1) |
May
(8) |
Jun
(7) |
Jul
(3) |
Aug
(1) |
Sep
|
Oct
(1) |
Nov
(9) |
Dec
(1) |
2011 |
Jan
(2) |
Feb
|
Mar
|
Apr
(3) |
May
(1) |
Jun
|
Jul
|
Aug
(14) |
Sep
(29) |
Oct
(3) |
Nov
|
Dec
(3) |
2012 |
Jan
|
Feb
|
Mar
|
Apr
(7) |
May
(6) |
Jun
(59) |
Jul
|
Aug
(8) |
Sep
(21) |
Oct
|
Nov
|
Dec
|
2013 |
Jan
(1) |
Feb
|
Mar
(10) |
Apr
|
May
(18) |
Jun
(25) |
Jul
(18) |
Aug
(1) |
Sep
(6) |
Oct
(28) |
Nov
(4) |
Dec
(13) |
2014 |
Jan
(7) |
Feb
(5) |
Mar
(4) |
Apr
(36) |
May
(3) |
Jun
(7) |
Jul
(46) |
Aug
(14) |
Sep
(12) |
Oct
(2) |
Nov
|
Dec
(12) |
2015 |
Jan
(4) |
Feb
|
Mar
|
Apr
(80) |
May
(36) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <wa...@us...> - 2010-01-24 19:13:29
|
Revision: 1406 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1406&view=rev Author: warnes Date: 2010-01-24 19:13:22 +0000 (Sun, 24 Jan 2010) Log Message: ----------- Make read.xls() and xls2sep() quieter when verbose=FALSE Modified Paths: -------------- trunk/gdata/R/read.xls.R trunk/gdata/R/xls2sep.R Modified: trunk/gdata/R/read.xls.R =================================================================== --- trunk/gdata/R/read.xls.R 2010-01-24 19:12:07 UTC (rev 1405) +++ trunk/gdata/R/read.xls.R 2010-01-24 19:13:22 UTC (rev 1406) @@ -25,8 +25,6 @@ { if(verbose) cat("Reading", method, "file ", dQuote.ascii(tfn), "...\n") - else - cat("Reading", method, "file... ") if(method=="csv") retval <- read.csv(con, ...) @@ -35,23 +33,24 @@ else stop("Unknown method", method) - cat("Done.\n") + if(verbose) + cat("Done.\n") } else { - cat("Searching for lines containing pattern ", pattern, "... ") + if(verbose) + cat("Searching for lines containing pattern ", pattern, "... ") idx <- grep(pattern, readLines(con)) if (length(idx) == 0) { warning("pattern not found") return(NULL) } - cat("Done.\n") + if(verbose) + cat("Done.\n") seek(con, 0) if(verbose) cat("Reading", method, "file ", dQuote.ascii(tfn), "...\n") - else - cat("Reading", method, "file... ") if(method=="csv") retval <- read.csv(con, skip = idx[1]-1, ...) @@ -62,7 +61,8 @@ close(con) - cat("Done.\n") + if(verbose) + cat("Done.\n") } retval } Modified: trunk/gdata/R/xls2sep.R =================================================================== --- trunk/gdata/R/xls2sep.R 2010-01-24 19:12:07 UTC (rev 1405) +++ trunk/gdata/R/xls2sep.R 2010-01-24 19:13:22 UTC (rev 1406) @@ -35,10 +35,8 @@ cat("Downloading", dQuote.ascii(xls), " to ", dQuote.ascii(tf), "...\n") - else - cat("Downloading...\n") download.file(xls, tf, mode = "wb") - cat("Done.\n") + if(verbose) cat("Done.\n") xls <- tf } @@ -88,8 +86,6 @@ cat(" ", dQuote.ascii(targetFile), "\n") cat("... \n\n") } - else - cat("Converting xls file to", method, "file... ") ## ## do the translation @@ -104,7 +100,7 @@ if(file.access(targetFile, 4)!=0) stop("Unable to read translated ", method, " file '", targetFile, "'." ) - cat("Done.\n") + if (verbose) cat("Done.\n") ## prepare for cleanup now, in case of error reading file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2010-01-24 19:12:20
|
Revision: 1405 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1405&view=rev Author: warnes Date: 2010-01-24 19:12:07 +0000 (Sun, 24 Jan 2010) Log Message: ----------- Add tests for read.xls, sheetCount, and sheetNames Added Paths: ----------- trunk/gdata/tests/test.read.xls.R trunk/gdata/tests/test.read.xls.Rout.save Added: trunk/gdata/tests/test.read.xls.R =================================================================== --- trunk/gdata/tests/test.read.xls.R (rev 0) +++ trunk/gdata/tests/test.read.xls.R 2010-01-24 19:12:07 UTC (rev 1405) @@ -0,0 +1,61 @@ +library(gdata) + + +# iris.xls is included in the gregmisc package for use as an example +xlsfile <- file.path(.path.package('gdata'),'xls','iris.xls') + +iris.1 <- read.xls(xlsfile) # defaults to csv format +iris.1 + +iris.2 <- read.xls(xlsfile,method="csv") # specify csv format +iris.2 + +iris.3 <- read.xls(xlsfile,method="tab") # specify tab format +iris.3 + +stopifnot(all.equal(iris.1, iris.2)) +stopifnot(all.equal(iris.1, iris.3)) + +exampleFile <- file.path(.path.package('gdata'),'xls', + 'ExampleExcelFile.xls') + +exampleFile2007 <- file.path(.path.package('gdata'),'xls', + 'ExampleExcelFile.xlsx') + +# see the number and names of sheets: +sheetCount(exampleFile) +sheetCount(exampleFile2007) + +sheetNames(exampleFile) +sheetNames(exampleFile2007) + +example.1 <- read.xls(exampleFile, sheet=1) # default is first worksheet +example.1 + +example.2 <- read.xls(exampleFile, sheet=2) # second worksheet by number +example.2 + +example.3 <- read.xls(exampleFile, sheet=3) # second worksheet by number +example.3 + +example.4 <- read.xls(exampleFile, sheet=3) # second worksheet by number +example.4 + +example.x.1 <- read.xls(exampleFile2007, sheet=1) # default is first worksheet +example.x.1 + +example.x.2 <- read.xls(exampleFile2007, sheet=2) # second worksheet by number +example.x.2 + +example.x.3 <- read.xls(exampleFile2007, sheet=3) # second worksheet by number +example.x.3 + +example.x.4 <- read.xls(exampleFile2007, sheet=3) # second worksheet by number +example.x.4 + +data <- read.xls(exampleFile2007, sheet="Sheet Second") # and by name +data + +# load the third worksheet, skipping the first two non-data lines... +data <- read.xls(exampleFile2007, sheet="Sheet with initial text", skip=2) +data Added: trunk/gdata/tests/test.read.xls.Rout.save =================================================================== --- trunk/gdata/tests/test.read.xls.Rout.save (rev 0) +++ trunk/gdata/tests/test.read.xls.Rout.save 2010-01-24 19:12:07 UTC (rev 1405) @@ -0,0 +1,627 @@ + +R version 2.10.1 (2009-12-14) +Copyright (C) 2009 The R Foundation for Statistical Computing +ISBN 3-900051-07-0 + +R is free software and comes with ABSOLUTELY NO WARRANTY. +You are welcome to redistribute it under certain conditions. +Type 'license()' or 'licence()' for distribution details. + + Natural language support but running in an English locale + +R is a collaborative project with many contributors. +Type 'contributors()' for more information and +'citation()' on how to cite R or R packages in publications. + +Type 'demo()' for some demos, 'help()' for on-line help, or +'help.start()' for an HTML browser interface to help. +Type 'q()' to quit R. + +> library(gdata) + +Attaching package: 'gdata' + + + The following object(s) are masked from package:utils : + + object.size + +> +> +> # iris.xls is included in the gregmisc package for use as an example +> xlsfile <- file.path(.path.package('gdata'),'xls','iris.xls') +> +> iris.1 <- read.xls(xlsfile) # defaults to csv format +> iris.1 + Sepal.Length Sepal.Width Petal.Length Petal.Width Species +1 5.1 3.5 1.4 0.2 setosa +2 4.9 3.0 1.4 0.2 setosa +3 4.7 3.2 1.3 0.2 setosa +4 4.6 3.1 1.5 0.2 setosa +5 5.0 3.6 1.4 0.2 setosa +6 5.4 3.9 1.7 0.4 setosa +7 4.6 3.4 1.4 0.3 setosa +8 5.0 3.4 1.5 0.2 setosa +9 4.4 2.9 1.4 0.2 setosa +10 4.9 3.1 1.5 0.1 setosa +11 5.4 3.7 1.5 0.2 setosa +12 4.8 3.4 1.6 0.2 setosa +13 4.8 3.0 1.4 0.1 setosa +14 4.3 3.0 1.1 0.1 setosa +15 5.8 4.0 1.2 0.2 setosa +16 5.7 4.4 1.5 0.4 setosa +17 5.4 3.9 1.3 0.4 setosa +18 5.1 3.5 1.4 0.3 setosa +19 5.7 3.8 1.7 0.3 setosa +20 5.1 3.8 1.5 0.3 setosa +21 5.4 3.4 1.7 0.2 setosa +22 5.1 3.7 1.5 0.4 setosa +23 4.6 3.6 1.0 0.2 setosa +24 5.1 3.3 1.7 0.5 setosa +25 4.8 3.4 1.9 0.2 setosa +26 5.0 3.0 1.6 0.2 setosa +27 5.0 3.4 1.6 0.4 setosa +28 5.2 3.5 1.5 0.2 setosa +29 5.2 3.4 1.4 0.2 setosa +30 4.7 3.2 1.6 0.2 setosa +31 4.8 3.1 1.6 0.2 setosa +32 5.4 3.4 1.5 0.4 setosa +33 5.2 4.1 1.5 0.1 setosa +34 5.5 4.2 1.4 0.2 setosa +35 4.9 3.1 1.5 0.2 setosa +36 5.0 3.2 1.2 0.2 setosa +37 5.5 3.5 1.3 0.2 setosa +38 4.9 3.6 1.4 0.1 setosa +39 4.4 3.0 1.3 0.2 setosa +40 5.1 3.4 1.5 0.2 setosa +41 5.0 3.5 1.3 0.3 setosa +42 4.5 2.3 1.3 0.3 setosa +43 4.4 3.2 1.3 0.2 setosa +44 5.0 3.5 1.6 0.6 setosa +45 5.1 3.8 1.9 0.4 setosa +46 4.8 3.0 1.4 0.3 setosa +47 5.1 3.8 1.6 0.2 setosa +48 4.6 3.2 1.4 0.2 setosa +49 5.3 3.7 1.5 0.2 setosa +50 5.0 3.3 1.4 0.2 setosa +51 7.0 3.2 4.7 1.4 versicolor +52 6.4 3.2 4.5 1.5 versicolor +53 6.9 3.1 4.9 1.5 versicolor +54 5.5 2.3 4.0 1.3 versicolor +55 6.5 2.8 4.6 1.5 versicolor +56 5.7 2.8 4.5 1.3 versicolor +57 6.3 3.3 4.7 1.6 versicolor +58 4.9 2.4 3.3 1.0 versicolor +59 6.6 2.9 4.6 1.3 versicolor +60 5.2 2.7 3.9 1.4 versicolor +61 5.0 2.0 3.5 1.0 versicolor +62 5.9 3.0 4.2 1.5 versicolor +63 6.0 2.2 4.0 1.0 versicolor +64 6.1 2.9 4.7 1.4 versicolor +65 5.6 2.9 3.6 1.3 versicolor +66 6.7 3.1 4.4 1.4 versicolor +67 5.6 3.0 4.5 1.5 versicolor +68 5.8 2.7 4.1 1.0 versicolor +69 6.2 2.2 4.5 1.5 versicolor +70 5.6 2.5 3.9 1.1 versicolor +71 5.9 3.2 4.8 1.8 versicolor +72 6.1 2.8 4.0 1.3 versicolor +73 6.3 2.5 4.9 1.5 versicolor +74 6.1 2.8 4.7 1.2 versicolor +75 6.4 2.9 4.3 1.3 versicolor +76 6.6 3.0 4.4 1.4 versicolor +77 6.8 2.8 4.8 1.4 versicolor +78 6.7 3.0 5.0 1.7 versicolor +79 6.0 2.9 4.5 1.5 versicolor +80 5.7 2.6 3.5 1.0 versicolor +81 5.5 2.4 3.8 1.1 versicolor +82 5.5 2.4 3.7 1.0 versicolor +83 5.8 2.7 3.9 1.2 versicolor +84 6.0 2.7 5.1 1.6 versicolor +85 5.4 3.0 4.5 1.5 versicolor +86 6.0 3.4 4.5 1.6 versicolor +87 6.7 3.1 4.7 1.5 versicolor +88 6.3 2.3 4.4 1.3 versicolor +89 5.6 3.0 4.1 1.3 versicolor +90 5.5 2.5 4.0 1.3 versicolor +91 5.5 2.6 4.4 1.2 versicolor +92 6.1 3.0 4.6 1.4 versicolor +93 5.8 2.6 4.0 1.2 versicolor +94 5.0 2.3 3.3 1.0 versicolor +95 5.6 2.7 4.2 1.3 versicolor +96 5.7 3.0 4.2 1.2 versicolor +97 5.7 2.9 4.2 1.3 versicolor +98 6.2 2.9 4.3 1.3 versicolor +99 5.1 2.5 3.0 1.1 versicolor +100 5.7 2.8 4.1 1.3 versicolor +101 6.3 3.3 6.0 2.5 virginica +102 5.8 2.7 5.1 1.9 virginica +103 7.1 3.0 5.9 2.1 virginica +104 6.3 2.9 5.6 1.8 virginica +105 6.5 3.0 5.8 2.2 virginica +106 7.6 3.0 6.6 2.1 virginica +107 4.9 2.5 4.5 1.7 virginica +108 7.3 2.9 6.3 1.8 virginica +109 6.7 2.5 5.8 1.8 virginica +110 7.2 3.6 6.1 2.5 virginica +111 6.5 3.2 5.1 2.0 virginica +112 6.4 2.7 5.3 1.9 virginica +113 6.8 3.0 5.5 2.1 virginica +114 5.7 2.5 5.0 2.0 virginica +115 5.8 2.8 5.1 2.4 virginica +116 6.4 3.2 5.3 2.3 virginica +117 6.5 3.0 5.5 1.8 virginica +118 7.7 3.8 6.7 2.2 virginica +119 7.7 2.6 6.9 2.3 virginica +120 6.0 2.2 5.0 1.5 virginica +121 6.9 3.2 5.7 2.3 virginica +122 5.6 2.8 4.9 2.0 virginica +123 7.7 2.8 6.7 2.0 virginica +124 6.3 2.7 4.9 1.8 virginica +125 6.7 3.3 5.7 2.1 virginica +126 7.2 3.2 6.0 1.8 virginica +127 6.2 2.8 4.8 1.8 virginica +128 6.1 3.0 4.9 1.8 virginica +129 6.4 2.8 5.6 2.1 virginica +130 7.2 3.0 5.8 1.6 virginica +131 7.4 2.8 6.1 1.9 virginica +132 7.9 3.8 6.4 2.0 virginica +133 6.4 2.8 5.6 2.2 virginica +134 6.3 2.8 5.1 1.5 virginica +135 6.1 2.6 5.6 1.4 virginica +136 7.7 3.0 6.1 2.3 virginica +137 6.3 3.4 5.6 2.4 virginica +138 6.4 3.1 5.5 1.8 virginica +139 6.0 3.0 4.8 1.8 virginica +140 6.9 3.1 5.4 2.1 virginica +141 6.7 3.1 5.6 2.4 virginica +142 6.9 3.1 5.1 2.3 virginica +143 5.8 2.7 5.1 1.9 virginica +144 6.8 3.2 5.9 2.3 virginica +145 6.7 3.3 5.7 2.5 virginica +146 6.7 3.0 5.2 2.3 virginica +147 6.3 2.5 5.0 1.9 virginica +148 6.5 3.0 5.2 2.0 virginica +149 6.2 3.4 5.4 2.3 virginica +150 5.9 3.0 5.1 1.8 virginica +> +> iris.2 <- read.xls(xlsfile,method="csv") # specify csv format +> iris.2 + Sepal.Length Sepal.Width Petal.Length Petal.Width Species +1 5.1 3.5 1.4 0.2 setosa +2 4.9 3.0 1.4 0.2 setosa +3 4.7 3.2 1.3 0.2 setosa +4 4.6 3.1 1.5 0.2 setosa +5 5.0 3.6 1.4 0.2 setosa +6 5.4 3.9 1.7 0.4 setosa +7 4.6 3.4 1.4 0.3 setosa +8 5.0 3.4 1.5 0.2 setosa +9 4.4 2.9 1.4 0.2 setosa +10 4.9 3.1 1.5 0.1 setosa +11 5.4 3.7 1.5 0.2 setosa +12 4.8 3.4 1.6 0.2 setosa +13 4.8 3.0 1.4 0.1 setosa +14 4.3 3.0 1.1 0.1 setosa +15 5.8 4.0 1.2 0.2 setosa +16 5.7 4.4 1.5 0.4 setosa +17 5.4 3.9 1.3 0.4 setosa +18 5.1 3.5 1.4 0.3 setosa +19 5.7 3.8 1.7 0.3 setosa +20 5.1 3.8 1.5 0.3 setosa +21 5.4 3.4 1.7 0.2 setosa +22 5.1 3.7 1.5 0.4 setosa +23 4.6 3.6 1.0 0.2 setosa +24 5.1 3.3 1.7 0.5 setosa +25 4.8 3.4 1.9 0.2 setosa +26 5.0 3.0 1.6 0.2 setosa +27 5.0 3.4 1.6 0.4 setosa +28 5.2 3.5 1.5 0.2 setosa +29 5.2 3.4 1.4 0.2 setosa +30 4.7 3.2 1.6 0.2 setosa +31 4.8 3.1 1.6 0.2 setosa +32 5.4 3.4 1.5 0.4 setosa +33 5.2 4.1 1.5 0.1 setosa +34 5.5 4.2 1.4 0.2 setosa +35 4.9 3.1 1.5 0.2 setosa +36 5.0 3.2 1.2 0.2 setosa +37 5.5 3.5 1.3 0.2 setosa +38 4.9 3.6 1.4 0.1 setosa +39 4.4 3.0 1.3 0.2 setosa +40 5.1 3.4 1.5 0.2 setosa +41 5.0 3.5 1.3 0.3 setosa +42 4.5 2.3 1.3 0.3 setosa +43 4.4 3.2 1.3 0.2 setosa +44 5.0 3.5 1.6 0.6 setosa +45 5.1 3.8 1.9 0.4 setosa +46 4.8 3.0 1.4 0.3 setosa +47 5.1 3.8 1.6 0.2 setosa +48 4.6 3.2 1.4 0.2 setosa +49 5.3 3.7 1.5 0.2 setosa +50 5.0 3.3 1.4 0.2 setosa +51 7.0 3.2 4.7 1.4 versicolor +52 6.4 3.2 4.5 1.5 versicolor +53 6.9 3.1 4.9 1.5 versicolor +54 5.5 2.3 4.0 1.3 versicolor +55 6.5 2.8 4.6 1.5 versicolor +56 5.7 2.8 4.5 1.3 versicolor +57 6.3 3.3 4.7 1.6 versicolor +58 4.9 2.4 3.3 1.0 versicolor +59 6.6 2.9 4.6 1.3 versicolor +60 5.2 2.7 3.9 1.4 versicolor +61 5.0 2.0 3.5 1.0 versicolor +62 5.9 3.0 4.2 1.5 versicolor +63 6.0 2.2 4.0 1.0 versicolor +64 6.1 2.9 4.7 1.4 versicolor +65 5.6 2.9 3.6 1.3 versicolor +66 6.7 3.1 4.4 1.4 versicolor +67 5.6 3.0 4.5 1.5 versicolor +68 5.8 2.7 4.1 1.0 versicolor +69 6.2 2.2 4.5 1.5 versicolor +70 5.6 2.5 3.9 1.1 versicolor +71 5.9 3.2 4.8 1.8 versicolor +72 6.1 2.8 4.0 1.3 versicolor +73 6.3 2.5 4.9 1.5 versicolor +74 6.1 2.8 4.7 1.2 versicolor +75 6.4 2.9 4.3 1.3 versicolor +76 6.6 3.0 4.4 1.4 versicolor +77 6.8 2.8 4.8 1.4 versicolor +78 6.7 3.0 5.0 1.7 versicolor +79 6.0 2.9 4.5 1.5 versicolor +80 5.7 2.6 3.5 1.0 versicolor +81 5.5 2.4 3.8 1.1 versicolor +82 5.5 2.4 3.7 1.0 versicolor +83 5.8 2.7 3.9 1.2 versicolor +84 6.0 2.7 5.1 1.6 versicolor +85 5.4 3.0 4.5 1.5 versicolor +86 6.0 3.4 4.5 1.6 versicolor +87 6.7 3.1 4.7 1.5 versicolor +88 6.3 2.3 4.4 1.3 versicolor +89 5.6 3.0 4.1 1.3 versicolor +90 5.5 2.5 4.0 1.3 versicolor +91 5.5 2.6 4.4 1.2 versicolor +92 6.1 3.0 4.6 1.4 versicolor +93 5.8 2.6 4.0 1.2 versicolor +94 5.0 2.3 3.3 1.0 versicolor +95 5.6 2.7 4.2 1.3 versicolor +96 5.7 3.0 4.2 1.2 versicolor +97 5.7 2.9 4.2 1.3 versicolor +98 6.2 2.9 4.3 1.3 versicolor +99 5.1 2.5 3.0 1.1 versicolor +100 5.7 2.8 4.1 1.3 versicolor +101 6.3 3.3 6.0 2.5 virginica +102 5.8 2.7 5.1 1.9 virginica +103 7.1 3.0 5.9 2.1 virginica +104 6.3 2.9 5.6 1.8 virginica +105 6.5 3.0 5.8 2.2 virginica +106 7.6 3.0 6.6 2.1 virginica +107 4.9 2.5 4.5 1.7 virginica +108 7.3 2.9 6.3 1.8 virginica +109 6.7 2.5 5.8 1.8 virginica +110 7.2 3.6 6.1 2.5 virginica +111 6.5 3.2 5.1 2.0 virginica +112 6.4 2.7 5.3 1.9 virginica +113 6.8 3.0 5.5 2.1 virginica +114 5.7 2.5 5.0 2.0 virginica +115 5.8 2.8 5.1 2.4 virginica +116 6.4 3.2 5.3 2.3 virginica +117 6.5 3.0 5.5 1.8 virginica +118 7.7 3.8 6.7 2.2 virginica +119 7.7 2.6 6.9 2.3 virginica +120 6.0 2.2 5.0 1.5 virginica +121 6.9 3.2 5.7 2.3 virginica +122 5.6 2.8 4.9 2.0 virginica +123 7.7 2.8 6.7 2.0 virginica +124 6.3 2.7 4.9 1.8 virginica +125 6.7 3.3 5.7 2.1 virginica +126 7.2 3.2 6.0 1.8 virginica +127 6.2 2.8 4.8 1.8 virginica +128 6.1 3.0 4.9 1.8 virginica +129 6.4 2.8 5.6 2.1 virginica +130 7.2 3.0 5.8 1.6 virginica +131 7.4 2.8 6.1 1.9 virginica +132 7.9 3.8 6.4 2.0 virginica +133 6.4 2.8 5.6 2.2 virginica +134 6.3 2.8 5.1 1.5 virginica +135 6.1 2.6 5.6 1.4 virginica +136 7.7 3.0 6.1 2.3 virginica +137 6.3 3.4 5.6 2.4 virginica +138 6.4 3.1 5.5 1.8 virginica +139 6.0 3.0 4.8 1.8 virginica +140 6.9 3.1 5.4 2.1 virginica +141 6.7 3.1 5.6 2.4 virginica +142 6.9 3.1 5.1 2.3 virginica +143 5.8 2.7 5.1 1.9 virginica +144 6.8 3.2 5.9 2.3 virginica +145 6.7 3.3 5.7 2.5 virginica +146 6.7 3.0 5.2 2.3 virginica +147 6.3 2.5 5.0 1.9 virginica +148 6.5 3.0 5.2 2.0 virginica +149 6.2 3.4 5.4 2.3 virginica +150 5.9 3.0 5.1 1.8 virginica +> +> iris.3 <- read.xls(xlsfile,method="tab") # specify tab format +> iris.3 + Sepal.Length Sepal.Width Petal.Length Petal.Width Species +1 5.1 3.5 1.4 0.2 setosa +2 4.9 3.0 1.4 0.2 setosa +3 4.7 3.2 1.3 0.2 setosa +4 4.6 3.1 1.5 0.2 setosa +5 5.0 3.6 1.4 0.2 setosa +6 5.4 3.9 1.7 0.4 setosa +7 4.6 3.4 1.4 0.3 setosa +8 5.0 3.4 1.5 0.2 setosa +9 4.4 2.9 1.4 0.2 setosa +10 4.9 3.1 1.5 0.1 setosa +11 5.4 3.7 1.5 0.2 setosa +12 4.8 3.4 1.6 0.2 setosa +13 4.8 3.0 1.4 0.1 setosa +14 4.3 3.0 1.1 0.1 setosa +15 5.8 4.0 1.2 0.2 setosa +16 5.7 4.4 1.5 0.4 setosa +17 5.4 3.9 1.3 0.4 setosa +18 5.1 3.5 1.4 0.3 setosa +19 5.7 3.8 1.7 0.3 setosa +20 5.1 3.8 1.5 0.3 setosa +21 5.4 3.4 1.7 0.2 setosa +22 5.1 3.7 1.5 0.4 setosa +23 4.6 3.6 1.0 0.2 setosa +24 5.1 3.3 1.7 0.5 setosa +25 4.8 3.4 1.9 0.2 setosa +26 5.0 3.0 1.6 0.2 setosa +27 5.0 3.4 1.6 0.4 setosa +28 5.2 3.5 1.5 0.2 setosa +29 5.2 3.4 1.4 0.2 setosa +30 4.7 3.2 1.6 0.2 setosa +31 4.8 3.1 1.6 0.2 setosa +32 5.4 3.4 1.5 0.4 setosa +33 5.2 4.1 1.5 0.1 setosa +34 5.5 4.2 1.4 0.2 setosa +35 4.9 3.1 1.5 0.2 setosa +36 5.0 3.2 1.2 0.2 setosa +37 5.5 3.5 1.3 0.2 setosa +38 4.9 3.6 1.4 0.1 setosa +39 4.4 3.0 1.3 0.2 setosa +40 5.1 3.4 1.5 0.2 setosa +41 5.0 3.5 1.3 0.3 setosa +42 4.5 2.3 1.3 0.3 setosa +43 4.4 3.2 1.3 0.2 setosa +44 5.0 3.5 1.6 0.6 setosa +45 5.1 3.8 1.9 0.4 setosa +46 4.8 3.0 1.4 0.3 setosa +47 5.1 3.8 1.6 0.2 setosa +48 4.6 3.2 1.4 0.2 setosa +49 5.3 3.7 1.5 0.2 setosa +50 5.0 3.3 1.4 0.2 setosa +51 7.0 3.2 4.7 1.4 versicolor +52 6.4 3.2 4.5 1.5 versicolor +53 6.9 3.1 4.9 1.5 versicolor +54 5.5 2.3 4.0 1.3 versicolor +55 6.5 2.8 4.6 1.5 versicolor +56 5.7 2.8 4.5 1.3 versicolor +57 6.3 3.3 4.7 1.6 versicolor +58 4.9 2.4 3.3 1.0 versicolor +59 6.6 2.9 4.6 1.3 versicolor +60 5.2 2.7 3.9 1.4 versicolor +61 5.0 2.0 3.5 1.0 versicolor +62 5.9 3.0 4.2 1.5 versicolor +63 6.0 2.2 4.0 1.0 versicolor +64 6.1 2.9 4.7 1.4 versicolor +65 5.6 2.9 3.6 1.3 versicolor +66 6.7 3.1 4.4 1.4 versicolor +67 5.6 3.0 4.5 1.5 versicolor +68 5.8 2.7 4.1 1.0 versicolor +69 6.2 2.2 4.5 1.5 versicolor +70 5.6 2.5 3.9 1.1 versicolor +71 5.9 3.2 4.8 1.8 versicolor +72 6.1 2.8 4.0 1.3 versicolor +73 6.3 2.5 4.9 1.5 versicolor +74 6.1 2.8 4.7 1.2 versicolor +75 6.4 2.9 4.3 1.3 versicolor +76 6.6 3.0 4.4 1.4 versicolor +77 6.8 2.8 4.8 1.4 versicolor +78 6.7 3.0 5.0 1.7 versicolor +79 6.0 2.9 4.5 1.5 versicolor +80 5.7 2.6 3.5 1.0 versicolor +81 5.5 2.4 3.8 1.1 versicolor +82 5.5 2.4 3.7 1.0 versicolor +83 5.8 2.7 3.9 1.2 versicolor +84 6.0 2.7 5.1 1.6 versicolor +85 5.4 3.0 4.5 1.5 versicolor +86 6.0 3.4 4.5 1.6 versicolor +87 6.7 3.1 4.7 1.5 versicolor +88 6.3 2.3 4.4 1.3 versicolor +89 5.6 3.0 4.1 1.3 versicolor +90 5.5 2.5 4.0 1.3 versicolor +91 5.5 2.6 4.4 1.2 versicolor +92 6.1 3.0 4.6 1.4 versicolor +93 5.8 2.6 4.0 1.2 versicolor +94 5.0 2.3 3.3 1.0 versicolor +95 5.6 2.7 4.2 1.3 versicolor +96 5.7 3.0 4.2 1.2 versicolor +97 5.7 2.9 4.2 1.3 versicolor +98 6.2 2.9 4.3 1.3 versicolor +99 5.1 2.5 3.0 1.1 versicolor +100 5.7 2.8 4.1 1.3 versicolor +101 6.3 3.3 6.0 2.5 virginica +102 5.8 2.7 5.1 1.9 virginica +103 7.1 3.0 5.9 2.1 virginica +104 6.3 2.9 5.6 1.8 virginica +105 6.5 3.0 5.8 2.2 virginica +106 7.6 3.0 6.6 2.1 virginica +107 4.9 2.5 4.5 1.7 virginica +108 7.3 2.9 6.3 1.8 virginica +109 6.7 2.5 5.8 1.8 virginica +110 7.2 3.6 6.1 2.5 virginica +111 6.5 3.2 5.1 2.0 virginica +112 6.4 2.7 5.3 1.9 virginica +113 6.8 3.0 5.5 2.1 virginica +114 5.7 2.5 5.0 2.0 virginica +115 5.8 2.8 5.1 2.4 virginica +116 6.4 3.2 5.3 2.3 virginica +117 6.5 3.0 5.5 1.8 virginica +118 7.7 3.8 6.7 2.2 virginica +119 7.7 2.6 6.9 2.3 virginica +120 6.0 2.2 5.0 1.5 virginica +121 6.9 3.2 5.7 2.3 virginica +122 5.6 2.8 4.9 2.0 virginica +123 7.7 2.8 6.7 2.0 virginica +124 6.3 2.7 4.9 1.8 virginica +125 6.7 3.3 5.7 2.1 virginica +126 7.2 3.2 6.0 1.8 virginica +127 6.2 2.8 4.8 1.8 virginica +128 6.1 3.0 4.9 1.8 virginica +129 6.4 2.8 5.6 2.1 virginica +130 7.2 3.0 5.8 1.6 virginica +131 7.4 2.8 6.1 1.9 virginica +132 7.9 3.8 6.4 2.0 virginica +133 6.4 2.8 5.6 2.2 virginica +134 6.3 2.8 5.1 1.5 virginica +135 6.1 2.6 5.6 1.4 virginica +136 7.7 3.0 6.1 2.3 virginica +137 6.3 3.4 5.6 2.4 virginica +138 6.4 3.1 5.5 1.8 virginica +139 6.0 3.0 4.8 1.8 virginica +140 6.9 3.1 5.4 2.1 virginica +141 6.7 3.1 5.6 2.4 virginica +142 6.9 3.1 5.1 2.3 virginica +143 5.8 2.7 5.1 1.9 virginica +144 6.8 3.2 5.9 2.3 virginica +145 6.7 3.3 5.7 2.5 virginica +146 6.7 3.0 5.2 2.3 virginica +147 6.3 2.5 5.0 1.9 virginica +148 6.5 3.0 5.2 2.0 virginica +149 6.2 3.4 5.4 2.3 virginica +150 5.9 3.0 5.1 1.8 virginica +> +> stopifnot(all.equal(iris.1, iris.2)) +> stopifnot(all.equal(iris.1, iris.3)) +> +> exampleFile <- file.path(.path.package('gdata'),'xls', ++ 'ExampleExcelFile.xls') +> +> exampleFile2007 <- file.path(.path.package('gdata'),'xls', ++ 'ExampleExcelFile.xlsx') +> +> # see the number and names of sheets: +> sheetCount(exampleFile) +[1] 4 +> sheetCount(exampleFile2007) +[1] 4 +> +> sheetNames(exampleFile) +[1] "Sheet First" "Sheet Second" +[3] "Sheet with a very long name!" "Sheet with initial text" +> sheetNames(exampleFile2007) +[1] "Sheet First" "Sheet Second" +[3] "Sheet with a very long name!" "Sheet with initial text" +> +> example.1 <- read.xls(exampleFile, sheet=1) # default is first worksheet +> example.1 + A B C +1 1 1 1 +2 2 4 8 +3 3 9 27 +4 4 16 64 +5 5 25 125 +6 6 36 216 +7 7 49 343 +> +> example.2 <- read.xls(exampleFile, sheet=2) # second worksheet by number +> example.2 + X D E F G Factor +1 FirstRow 1 NA NA NA Red +2 SecondRow 2 1 NA NA Green +3 ThirdRow 3 2 1 NA Red +4 FourthRow 4 3 2 1 Black +> +> example.3 <- read.xls(exampleFile, sheet=3) # second worksheet by number +> example.3 + X1 X2001.01.01 X1.01 X0.205818150587141 X.DIV.0. A +1 2 2002-02-02 2:02 0.2910708 NA B +2 3 2003-03-03 3:03 0.3564875 -0.8414710 C +3 4 2004-04-04 4:04 0.4116363 0.7080734 +4 5 2005-05-05 5:05 0.4602234 0.5013680 A +5 6 2006-06-06 6:06 NA 0.2513698 B +6 7 2007-07-07 7:07 0.5445436 0.0631868 B +7 8 2008-08-08 8:08 0.5821416 NA C +8 9 2009-09-09 9:09 0.6174545 0.0000000 A +9 10 2010-10-10 10:10 0.6508541 0.0000000 A +> +> example.4 <- read.xls(exampleFile, sheet=3) # second worksheet by number +> example.4 + X1 X2001.01.01 X1.01 X0.205818150587141 X.DIV.0. A +1 2 2002-02-02 2:02 0.2910708 NA B +2 3 2003-03-03 3:03 0.3564875 -0.8414710 C +3 4 2004-04-04 4:04 0.4116363 0.7080734 +4 5 2005-05-05 5:05 0.4602234 0.5013680 A +5 6 2006-06-06 6:06 NA 0.2513698 B +6 7 2007-07-07 7:07 0.5445436 0.0631868 B +7 8 2008-08-08 8:08 0.5821416 NA C +8 9 2009-09-09 9:09 0.6174545 0.0000000 A +9 10 2010-10-10 10:10 0.6508541 0.0000000 A +> +> example.x.1 <- read.xls(exampleFile2007, sheet=1) # default is first worksheet +> example.x.1 + A B C +1 1 1 1 +2 2 4 8 +3 3 9 27 +4 4 16 64 +5 5 25 125 +6 6 36 216 +7 7 49 343 +> +> example.x.2 <- read.xls(exampleFile2007, sheet=2) # second worksheet by number +> example.x.2 + X D E F G Factor +1 FirstRow 1 NA NA NA Red +2 SecondRow 2 1 NA NA Green +3 ThirdRow 3 2 1 NA Red +4 FourthRow 4 3 2 1 Black +> +> example.x.3 <- read.xls(exampleFile2007, sheet=3) # second worksheet by number +> example.x.3 + X1 X2001.01.01 X1.01 X0.205818150587141 X.DIV.0. A +1 2 2002-02-02 2:02 0.2910708 NA B +2 3 2003-03-03 3:03 0.3564875 -0.8414710 C +3 4 2004-04-04 4:04 0.4116363 0.7080734 +4 5 2005-05-05 5:05 0.4602234 0.5013680 A +5 6 2006-06-06 6:06 NA 0.2513698 B +6 7 2007-07-07 7:07 0.5445436 0.0631868 B +7 8 2008-08-08 8:08 0.5821416 NA C +8 9 2009-09-09 9:09 0.6174545 0.0000000 A +9 10 2010-10-10 10:10 0.6508541 0.0000000 A +> +> example.x.4 <- read.xls(exampleFile2007, sheet=3) # second worksheet by number +> example.x.4 + X1 X2001.01.01 X1.01 X0.205818150587141 X.DIV.0. A +1 2 2002-02-02 2:02 0.2910708 NA B +2 3 2003-03-03 3:03 0.3564875 -0.8414710 C +3 4 2004-04-04 4:04 0.4116363 0.7080734 +4 5 2005-05-05 5:05 0.4602234 0.5013680 A +5 6 2006-06-06 6:06 NA 0.2513698 B +6 7 2007-07-07 7:07 0.5445436 0.0631868 B +7 8 2008-08-08 8:08 0.5821416 NA C +8 9 2009-09-09 9:09 0.6174545 0.0000000 A +9 10 2010-10-10 10:10 0.6508541 0.0000000 A +> +> data <- read.xls(exampleFile2007, sheet="Sheet Second") # and by name +> data + X D E F G Factor +1 FirstRow 1 NA NA NA Red +2 SecondRow 2 1 NA NA Green +3 ThirdRow 3 2 1 NA Red +4 FourthRow 4 3 2 1 Black +> +> # load the third worksheet, skipping the first two non-data lines... +> data <- read.xls(exampleFile2007, sheet="Sheet with initial text", skip=2) +> data + X X.1 D E F G Factor +1 NA FirstRow 1 NA NA NA Red +2 NA SecondRow 2 1 NA NA Green +3 NA ThirdRow 3 2 1 NA Red +4 NA FourthRow 4 3 2 1 Black +> +> proc.time() + user system elapsed + 2.787 2.477 3.347 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2010-01-24 18:22:17
|
Revision: 1404 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1404&view=rev Author: warnes Date: 2010-01-24 18:22:08 +0000 (Sun, 24 Jan 2010) Log Message: ----------- Modify makefile to 1) clean up after build, 2) make tar non-verbose Modified Paths: -------------- trunk/gdata/src/Makefile Modified: trunk/gdata/src/Makefile =================================================================== --- trunk/gdata/src/Makefile 2010-01-24 18:19:33 UTC (rev 1403) +++ trunk/gdata/src/Makefile 2010-01-24 18:22:08 UTC (rev 1404) @@ -1,13 +1,15 @@ TARGET=Compress-Raw-Zlib-2.024 default: - tar xvf ${TARGET}.tar.gz + tar xzf ${TARGET}.tar.gz cd ${TARGET} ; \ perl Makefile.PL PREFIX=${PWD}/../inst/perl LIB=${PWD}/../inst/perl ; \ make; \ make install + # + make clean clean: rm -rf ${TARGET} rm -rf ../inst/perl/share - rm -rf ../inst/perl/darwin-2level + #rm -rf ../inst/perl/darwin-2level This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2010-01-24 18:19:39
|
Revision: 1403 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1403&view=rev Author: warnes Date: 2010-01-24 18:19:33 +0000 (Sun, 24 Jan 2010) Log Message: ----------- Close connections when done. Modified Paths: -------------- trunk/gdata/R/read.xls.R trunk/gdata/R/sheetCount.R Modified: trunk/gdata/R/read.xls.R =================================================================== --- trunk/gdata/R/read.xls.R 2010-01-24 18:17:26 UTC (rev 1402) +++ trunk/gdata/R/read.xls.R 2010-01-24 18:19:33 UTC (rev 1403) @@ -60,6 +60,8 @@ else stop("Unknown method", method) + close(con) + cat("Done.\n") } retval Modified: trunk/gdata/R/sheetCount.R =================================================================== --- trunk/gdata/R/sheetCount.R 2010-01-24 18:17:26 UTC (rev 1402) +++ trunk/gdata/R/sheetCount.R 2010-01-24 18:19:33 UTC (rev 1403) @@ -57,6 +57,7 @@ results <- system(cmd, intern=TRUE) tc <- textConnection(results) results <- read.table(tc, as.is=TRUE, header=FALSE) + close(tc) results <- unlist(results) names(results) <- NULL ## This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2010-01-24 18:17:32
|
Revision: 1402 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1402&view=rev Author: warnes Date: 2010-01-24 18:17:26 +0000 (Sun, 24 Jan 2010) Log Message: ----------- Fix typo Modified Paths: -------------- trunk/gdata/man/read.xls.Rd Modified: trunk/gdata/man/read.xls.Rd =================================================================== --- trunk/gdata/man/read.xls.Rd 2010-01-24 18:10:03 UTC (rev 1401) +++ trunk/gdata/man/read.xls.Rd 2010-01-24 18:17:26 UTC (rev 1402) @@ -27,8 +27,8 @@ \item{perl}{name of the perl executable to be called.} \item{method}{intermediate file format, "csv" for comma-separated and "tab" for tab-separated} - \item{...}{additional arguments to read.table. The defaults of - read.csv are used.} + \item{...}{additional arguments to read.table. The defaults for + read.csv() are used.} } \value{ \code{"read.xls"} returns a data frame. @@ -54,7 +54,7 @@ \note{ Either a working version of Perl must be present in the executable search path, or the exact path of the perl executable must be provided via the \code{perl} argument. See the examples below for an illustration.} -\seealso{ \code{\link[base]{read.csv}} } +\seealso{ \code{\link[utils]{read.csv}} } \examples{ # iris.xls is included in the gregmisc package for use as an example This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2010-01-24 18:10:12
|
Revision: 1401 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1401&view=rev Author: warnes Date: 2010-01-24 18:10:03 +0000 (Sun, 24 Jan 2010) Log Message: ----------- Fix R CMD CHECK errors Modified Paths: -------------- trunk/gdata/man/read.xls.Rd Removed Paths: ------------- trunk/gdata/man/sheetNames.Rd Modified: trunk/gdata/man/read.xls.Rd =================================================================== --- trunk/gdata/man/read.xls.Rd 2010-01-24 08:47:27 UTC (rev 1400) +++ trunk/gdata/man/read.xls.Rd 2010-01-24 18:10:03 UTC (rev 1401) @@ -113,7 +113,7 @@ data <- read.xls(exampleFile) # default is first worksheet data <- read.xls(exampleFile, sheet=2) # second worksheet by number - data <- read.xls(exampleFile, sheet="Sheet Second",v=T) # and by name + data <- read.xls(exampleFile, sheet="Sheet Second",v=TRUE) # and by name # load the third worksheet, skipping the first two non-data lines... data <- read.xls(exampleFile2007, sheet="Sheet with initial text", skip=2) Deleted: trunk/gdata/man/sheetNames.Rd =================================================================== --- trunk/gdata/man/sheetNames.Rd 2010-01-24 08:47:27 UTC (rev 1400) +++ trunk/gdata/man/sheetNames.Rd 2010-01-24 18:10:03 UTC (rev 1401) @@ -1,42 +0,0 @@ -\name{sheetNames} -\Rdversion{1.1} -\alias{sheetCount} -\alias{sheetNames} -\title{ -Count sheets in Excel xls spreadsheet. -} -\description{ -Count the sheets in an Excel xls spreadsheet. -} -\usage{ -sheetCount(xls, verbose = FALSE, perl = "perl") -sheetNames(xls, verbose = FALSE, perl = "perl") -} -%- maybe also 'usage' for other objects documented here. -\arguments{ - \item{xls}{ -File path to spreadsheet. Is downloaded if it begins with \code{"http://"}.} - \item{verbose}{ - If \code{TRUE} additional information displayed. -} - \item{perl}{ - Path and file of perl interpreter or just \code{"perl"} if perl on path. -} -} -\value{ -\code{sheetCount} returns the number of sheets in the spreadsheet -and \code{sheetNames} returns -a character vector containing the sheet names in the spreadsheet. -} - -\seealso{ - \code{\link{read.xls}}, \code{\link{xls2csv}}. -} -\examples{ - xlsfile <- system.file("xls", "iris.xls", package = "gdata") - xlsfile - - sheetCount(xlsfile) - -} -\keyword{ misc } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2010-01-24 08:47:33
|
Revision: 1400 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1400&view=rev Author: warnes Date: 2010-01-24 08:47:27 +0000 (Sun, 24 Jan 2010) Log Message: ----------- Use the original gz file for Compress::Raw::Zlib to avoid issues with 'non-platform-independent' filename error in R CMD CHECK Modified Paths: -------------- trunk/gdata/src/Makefile Added Paths: ----------- trunk/gdata/src/Compress-Raw-Zlib-2.024.tar.gz Removed Paths: ------------- trunk/gdata/src/Compress-Raw-Zlib-2.024/ Added: trunk/gdata/src/Compress-Raw-Zlib-2.024.tar.gz =================================================================== (Binary files differ) Property changes on: trunk/gdata/src/Compress-Raw-Zlib-2.024.tar.gz ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/gdata/src/Makefile =================================================================== --- trunk/gdata/src/Makefile 2010-01-24 08:38:25 UTC (rev 1399) +++ trunk/gdata/src/Makefile 2010-01-24 08:47:27 UTC (rev 1400) @@ -1,9 +1,13 @@ +TARGET=Compress-Raw-Zlib-2.024 + default: - cd Compress-Raw-Zlib-2.024 ; \ + tar xvf ${TARGET}.tar.gz + cd ${TARGET} ; \ perl Makefile.PL PREFIX=${PWD}/../inst/perl LIB=${PWD}/../inst/perl ; \ make; \ make install clean: - cd Compress-Raw-Zlib-2.024 ; \ - make clean \ No newline at end of file + rm -rf ${TARGET} + rm -rf ../inst/perl/share + rm -rf ../inst/perl/darwin-2level This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2010-01-24 08:33:40
|
Revision: 1398 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1398&view=rev Author: warnes Date: 2010-01-24 08:33:34 +0000 (Sun, 24 Jan 2010) Log Message: ----------- Update for 2.7.0 release Modified Paths: -------------- trunk/gdata/DESCRIPTION trunk/gdata/inst/NEWS trunk/gdata/inst/doc/mapLevels.pdf trunk/gdata/inst/doc/unknown.pdf Modified: trunk/gdata/DESCRIPTION =================================================================== --- trunk/gdata/DESCRIPTION 2010-01-24 08:21:24 UTC (rev 1397) +++ trunk/gdata/DESCRIPTION 2010-01-24 08:33:34 UTC (rev 1398) @@ -3,8 +3,8 @@ Description: Various R programming tools for data manipulation Depends: R (>= 2.6.0) Imports: gtools -Version: 2.6.1 -Date: 2009-08-19 +Version: 2.7.0 +Date: 2010-01-25 Author: Gregory R. Warnes, with contributions from Ben Bolker, Gregor Gorjanc, Gabor Grothendieck, Ales Korosec, Thomas Lumley, Don MacQueen, Arni Magnusson, Jim Rogers, and others Modified: trunk/gdata/inst/NEWS =================================================================== --- trunk/gdata/inst/NEWS 2010-01-24 08:21:24 UTC (rev 1397) +++ trunk/gdata/inst/NEWS 2010-01-24 08:33:34 UTC (rev 1398) @@ -1,3 +1,41 @@ +CHANGES IN 2.7.0 (2010-01-25) +----------------------------- + +Enhancements: + +- read.xls() now supports Excel 2007 'xlsx' files. + +- read.xls() now allows specification of worksheet by name + +- read.xls() now supports ftp URLs. + +- Improved ll() so user can limit output to specified classes + + + +New Functions: + +- sheetCount() and sheetNames() to determine the number and names of + worksheets in an Excel file, respecively. + +Bug Fixes: + +- Fix formatting warning in frameApply(). + +- Modify unit tests to avoid issues related to zime zones. + +- Resolve crash of "ll(.GlobalEnv)" + +- + +CHANGES IN 2.6.1 (2009-07-15) +----------------------------- + +Bug Fixes + +- Modify unit tests to avoid issues related to zime zones. + + CHANGES IN 2.6.0 (2009-07-15) ----------------------------- Modified: trunk/gdata/inst/doc/mapLevels.pdf =================================================================== (Binary files differ) Modified: trunk/gdata/inst/doc/unknown.pdf =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2010-01-24 08:21:31
|
Revision: 1397 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1397&view=rev Author: warnes Date: 2010-01-24 08:21:24 +0000 (Sun, 24 Jan 2010) Log Message: ----------- Add new functions to NAMESPACE Modified Paths: -------------- trunk/gdata/NAMESPACE Modified: trunk/gdata/NAMESPACE =================================================================== --- trunk/gdata/NAMESPACE 2010-01-24 08:19:54 UTC (rev 1396) +++ trunk/gdata/NAMESPACE 2010-01-24 08:21:24 UTC (rev 1397) @@ -35,6 +35,7 @@ write.fwf, xls2csv, xls2tab, + xls2tsv, xls2sep, ## Object size stuff This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2010-01-24 08:15:17
|
Revision: 1395 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1395&view=rev Author: warnes Date: 2010-01-24 08:15:10 +0000 (Sun, 24 Jan 2010) Log Message: ----------- Add/Update documentation Modified Paths: -------------- trunk/gdata/man/read.xls.Rd Added Paths: ----------- trunk/gdata/man/sheetCount.Rd Modified: trunk/gdata/man/read.xls.Rd =================================================================== --- trunk/gdata/man/read.xls.Rd 2010-01-24 08:06:23 UTC (rev 1394) +++ trunk/gdata/man/read.xls.Rd 2010-01-24 08:15:10 UTC (rev 1395) @@ -2,21 +2,22 @@ \alias{read.xls} \alias{xls2csv} \alias{xls2tab} +\alias{xls2tsv} \alias{xls2sep} \title{Read Excel files} -\description{Reads a Microsoft Excel file into a data frame} +\description{Read a Microsoft Excel file into a data frame} \usage{ -read.xls(xls, sheet=1, verbose=FALSE, pattern, ..., - method=c("csv","tab"), perl="perl") - +read.xls(xls, sheet = 1, verbose=FALSE, pattern, ..., + method=c("csv","tsv","tab"), perl="perl") xls2csv(xls, sheet=1, verbose=FALSE, ..., perl="perl") xls2tab(xls, sheet=1, verbose=FALSE, ..., perl="perl") -xls2sep(xls, sheet=1, verbose=FALSE, ..., method=c("csv","tab"), +xls2tsv(xls, sheet=1, verbose=FALSE, ..., perl="perl") +xls2sep(xls, sheet=1, verbose=FALSE, ..., method=c("csv","tsv","tab"), perl="perl") } \arguments{ - \item{xls}{path to the Microsoft Excel file. To access a file on the - internet, start the path with "http://".} + \item{xls}{path to the Microsoft Excel file. Supports "http://", + "https://", and "ftp://" URLS.} \item{sheet}{number of the sheet within the Excel file from which data are to be read} \item{verbose}{logical flag indicating whether details should be @@ -93,14 +94,34 @@ crime <- read.xls(crime.url, pattern = "State") # use of xls2csv - open con, print two lines, close con - con <- xls2csv(nba.url) + con <- xls2csv(crime.url) print(readLines(con, 2)) file.remove(summary(con)$description) } + + # Examples demonstrating selection of specific 'sheets' + # from the example XLS file 'ExampleExcelFile.xls' + exampleFile <- file.path(.path.package('gdata'),'xls', + 'ExampleExcelFile.xls') + exampleFile2007 <- file.path(.path.package('gdata'),'xls', + 'ExampleExcelFile.xlsx') + + # see the number and names of sheets: + sheetCount(exampleFile) + sheetNames(exampleFile2007) + + data <- read.xls(exampleFile) # default is first worksheet + data <- read.xls(exampleFile, sheet=2) # second worksheet by number + data <- read.xls(exampleFile, sheet="Sheet Second",v=T) # and by name + + # load the third worksheet, skipping the first two non-data lines... + data <- read.xls(exampleFile2007, sheet="Sheet with initial text", skip=2) + } -\author{Jim Rogers \email{jam...@pf...}, modified - and extended by Gregory R. Warnes \email{gr...@ra...} +\author{ + Gregory R. Warnes \email{gr...@ra...}, + Jim Rogers \email{jam...@pf...}, and Gabor Grothendiek \email{ggr...@gm...}. } \keyword{file} Added: trunk/gdata/man/sheetCount.Rd =================================================================== --- trunk/gdata/man/sheetCount.Rd (rev 0) +++ trunk/gdata/man/sheetCount.Rd 2010-01-24 08:15:10 UTC (rev 1395) @@ -0,0 +1,47 @@ +\name{sheetCount} +\Rdversion{1.1} +\alias{sheetCount} +\alias{sheetNames} +\title{ +Count or list sheet names in Excel spreadsheet files. +} +\description{ +Count or list sheet names in Excel spreadsheet files. +} +\usage{ +sheetCount(xls, verbose = FALSE, perl = "perl") +sheetNames(xls, verbose = FALSE, perl = "perl") +} +\arguments{ + \item{xls}{File path to spreadsheet. Supports "http://", + "https://", and "ftp://" URLS.} + \item{verbose}{If \code{TRUE}, show additional messages during + processing.} + \item{perl}{Path to perl interpreter.} +} +\value{ + \code{sheetCount} returns the number of sheets in the spreadsheet. + \code{sheetNames} returns the names of sheets in the spreadsheet. +} + +\seealso{ + \code{\link{read.xls}}, \code{\link{xls2csv}}. +} +\examples{ + xlsfile <- system.file("xls", "iris.xls", package = "gdata") + xlsfile + + sheetCount(xlsfile) + + + exampleFile <- file.path(.path.package('gdata'),'xls', + 'ExampleExcelFile.xls') + exampleFile2007 <- file.path(.path.package('gdata'),'xls', + 'ExampleExcelFile.xlsx') + + sheetCount(exampleFile) + sheetNames(exampleFile2007) + + +} +\keyword{ misc } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2010-01-24 08:06:29
|
Revision: 1394 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1394&view=rev Author: warnes Date: 2010-01-24 08:06:23 +0000 (Sun, 24 Jan 2010) Log Message: ----------- Minor formatting change Modified Paths: -------------- trunk/gdata/R/xls2sep.R Modified: trunk/gdata/R/xls2sep.R =================================================================== --- trunk/gdata/R/xls2sep.R 2010-01-24 07:54:36 UTC (rev 1393) +++ trunk/gdata/R/xls2sep.R 2010-01-24 08:06:23 UTC (rev 1394) @@ -12,7 +12,7 @@ xls2sep(xls=xls, sheet=sheet, verbose=verbose, ..., method="tsv", perl=perl) -xls2sep <- function(xls, sheet = 1, verbose=FALSE, ..., +xls2sep <- function(xls, sheet=1, verbose=FALSE, ..., method=c("csv","tsv","tab"), perl="perl") { @@ -25,7 +25,7 @@ ## ## - ## files + ## filesheet tf <- NULL if ( substring(xls, 1, 7) == "http://" || substring(xls, 1, 6) == "ftp://" ) @@ -70,8 +70,12 @@ ## ## execution command - cmd <- paste(perl, script, dQuote.ascii(xls), dQuote.ascii(targetFile), - dQuote.ascii(sheet), sep=" ") + cmd <- paste(dQuote(perl), + dQuote(script), + dQuote.ascii(xls), + dQuote.ascii(targetFile), + dQuote.ascii(sheet), + sep=" ") ## ## @@ -89,7 +93,7 @@ ## ## do the translation - if(verbose) cat("Executing ", cmd, "... \n\n") + if(verbose) cat("Executing '", cmd, "'... \n\n") ## results <- system(cmd, intern=!verbose) ## This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2010-01-24 07:54:42
|
Revision: 1393 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1393&view=rev Author: warnes Date: 2010-01-24 07:54:36 +0000 (Sun, 24 Jan 2010) Log Message: ----------- Add additional example files Modified Paths: -------------- trunk/gdata/inst/xls/ExampleExcelFile.xls trunk/gdata/inst/xls/ExampleExcelFile.xlsx Modified: trunk/gdata/inst/xls/ExampleExcelFile.xls =================================================================== (Binary files differ) Modified: trunk/gdata/inst/xls/ExampleExcelFile.xlsx =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2010-01-24 07:49:23
|
Revision: 1392 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1392&view=rev Author: warnes Date: 2010-01-24 07:49:16 +0000 (Sun, 24 Jan 2010) Log Message: ----------- Combine sheetCount.pl and sheetNames.pl and modify to support Excel 2007 'xlsx' format Modified Paths: -------------- trunk/gdata/inst/perl/sheetCount.pl trunk/gdata/inst/perl/xls2csv.pl Added Paths: ----------- trunk/gdata/inst/perl/sheetNames.pl Removed Paths: ------------- trunk/gdata/inst/perl/sheetNames.pl Modified: trunk/gdata/inst/perl/sheetCount.pl =================================================================== --- trunk/gdata/inst/perl/sheetCount.pl 2010-01-24 07:26:58 UTC (rev 1391) +++ trunk/gdata/inst/perl/sheetCount.pl 2010-01-24 07:49:16 UTC (rev 1392) @@ -2,23 +2,48 @@ BEGIN { use File::Basename; -unshift(@INC, dirname $0); +# Add current path to perl library search path +use lib dirname($0); } use strict; use Spreadsheet::ParseExcel; +use Spreadsheet::XLSX; +use File::Spec::Functions; # declare some varibles local -my($row, $col, $sheet, $cell, $usage, $basename, $sheetnumber, $filename); +my($row, $col, $sheet, $cell, $usage, + $filename, $volume, $directories, $whoami, + $basename, $sheetnumber, $filename, + $text); + ## +## Figure out whether I'm called as sheetCount.pl or sheetNames.pl +## +($volume,$directories,$whoami) = File::Spec->splitpath( $0 ); + +if($whoami eq "sheetCount.pl") + { + $text="number"; + } +elsif ($whoami eq "sheetNames.pl") + { + $text="names"; + } +else + { + die("This script is named '$whoami', but must be named either 'sheetCount.pl' or 'sheetNames.pl' to function properly.\n"); + } + +## ## Usage information ## $usage = <<EOF; sheetCount.pl <excel file> -Output is the number of sheets in the excel file. +Output is the $text of sheets in the excel file. EOF @@ -38,12 +63,44 @@ ## open spreadsheet ## -my $oExcel = new Spreadsheet::ParseExcel; - open(FH, "<$fileName") or die "Unable to open file '$fileName'.\n"; close(FH); -my $oBook = $oExcel->Parse($fileName); +my $oBook; -print $oBook->{SheetCount} , "\n"; +## First try as a Excel 2007+ 'xml' file +eval + { + local $SIG{__WARN__} = sub {}; + $oBook = Spreadsheet::XLSX -> new ($ARGV[0]); + }; +## Then Excel 97-2004 Format +if($@) + { + $oBook = new Spreadsheet::ParseExcel->Parse($ARGV[0]) or \ + die "Error parsing file '$ARGV[0]'.\n"; + } + +if($whoami eq "sheetCount.pl") + { + print $oBook->{SheetCount} , "\n"; + } +elsif ($whoami eq "sheetNames.pl") + { + ## Get list all worksheets in the file + my @sheetlist = (@{$oBook->{Worksheet}}); + + foreach my $sheet (@sheetlist) + { + print "\"$sheet->{Name}\" "; + } + + print "\n"; + } +else + { + die("This script is named '$whoami', but must be named either 'sheetCount.pl' or 'sheetNames.pl' to function properly.\n"); + } + + Deleted: trunk/gdata/inst/perl/sheetNames.pl =================================================================== --- trunk/gdata/inst/perl/sheetNames.pl 2010-01-24 07:26:58 UTC (rev 1391) +++ trunk/gdata/inst/perl/sheetNames.pl 2010-01-24 07:49:16 UTC (rev 1392) @@ -1,57 +0,0 @@ -#!/usr/bin/perl - -BEGIN { -use File::Basename; -unshift(@INC, dirname $0); -} - -use strict; -use Spreadsheet::ParseExcel; - -# declare some varibles local -my($row, $col, $sheet, $cell, $usage, $basename, $sheetnumber, $filename); - -## -## Usage information -## -$usage = <<EOF; - -sheetCount.pl <excel file> - -Output is the number of sheets in the excel file. - -EOF - -## -## parse arguments -## - -if(!defined($ARGV[0])) - { - print $usage; - exit 1; - } - -my $fileName=$ARGV[0]; - -## -## open spreadsheet -## - -my $oExcel = new Spreadsheet::ParseExcel; - -open(FH, "<$fileName") or die "Unable to open file '$fileName'.\n"; -close(FH); - -my $oBook = $oExcel->Parse($fileName); - -## Get list all worksheets in the file -my @sheetlist = (@{$oBook->{Worksheet}}); - -foreach my $sheet (@sheetlist) -{ - print "\"$sheet->{Name}\" "; -} - -print "\n"; - Added: trunk/gdata/inst/perl/sheetNames.pl =================================================================== --- trunk/gdata/inst/perl/sheetNames.pl (rev 0) +++ trunk/gdata/inst/perl/sheetNames.pl 2010-01-24 07:49:16 UTC (rev 1392) @@ -0,0 +1 @@ +link sheetCount.pl \ No newline at end of file Property changes on: trunk/gdata/inst/perl/sheetNames.pl ___________________________________________________________________ Added: svn:special + * Modified: trunk/gdata/inst/perl/xls2csv.pl =================================================================== --- trunk/gdata/inst/perl/xls2csv.pl 2010-01-24 07:26:58 UTC (rev 1391) +++ trunk/gdata/inst/perl/xls2csv.pl 2010-01-24 07:49:16 UTC (rev 1392) @@ -122,13 +122,13 @@ close(FH); print "Loading '$ARGV[0]'...\n"; - ## First try as a Excel 2007+ 'xml' file eval { local $SIG{__WARN__} = sub {}; $oBook = Spreadsheet::XLSX -> new ($ARGV[0]); }; +## Then Excel 97-2004 Format if($@) { $oBook = new Spreadsheet::ParseExcel->Parse($ARGV[0]) or \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2010-01-24 07:27:05
|
Revision: 1391 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1391&view=rev Author: warnes Date: 2010-01-24 07:26:58 +0000 (Sun, 24 Jan 2010) Log Message: ----------- Complete changes to handle Excel 2007 'xlsx' files Modified Paths: -------------- trunk/gdata/inst/perl/Spreadsheet/XLSX/Fmt2007.pm trunk/gdata/inst/perl/Spreadsheet/XLSX.pm trunk/gdata/inst/perl/xls2csv.pl Modified: trunk/gdata/inst/perl/Spreadsheet/XLSX/Fmt2007.pm =================================================================== --- trunk/gdata/inst/perl/Spreadsheet/XLSX/Fmt2007.pm 2010-01-24 05:36:58 UTC (rev 1390) +++ trunk/gdata/inst/perl/Spreadsheet/XLSX/Fmt2007.pm 2010-01-24 07:26:58 UTC (rev 1391) @@ -6,6 +6,7 @@ package Spreadsheet::XLSX::Fmt2007; use strict; use warnings; +use POSIX; use Spreadsheet::XLSX::Utility2007 qw(ExcelFmt); our $VERSION = '0.12'; # @@ -34,7 +35,7 @@ 0x14 => 'h:mm', 0x15 => 'h:mm:ss', 0x16 => 'm-d-yy h:mm', -#0x17-0x24 -- Differs in Natinal +#0x17-0x24 -- Differs in National 0x25 => '(#,##0_);(#,##0)', 0x26 => '(#,##0_);[RED](#,##0)', 0x27 => '(#,##0.00);(#,##0.00)', @@ -93,27 +94,49 @@ if ($oCell->{Type} eq 'Numeric') { if($oCell->{Format}){ $sFmtStr=$oCell->{Format}; - } elsif(int($oCell->{Val}) != $oCell->{Val}) { - $sFmtStr = '0.00'; - } - else { + } + # Integer + elsif( isdigit($oCell->{Val}) ){ $sFmtStr = '0'; - } - } + } + # Floating Point + else{ + $sFmtStr = '0.000000000000000'; + } + } elsif($oCell->{Type} eq 'Date') { if($oCell->{Format}){ $sFmtStr=$oCell->{Format}; - } elsif(int($oCell->{Val}) <= 0) { - $sFmtStr = 'h:mm:ss'; - } + } + # Fraction < 1 --> Time + elsif(int($oCell->{Val}) <= 0){ + $sFmtStr = 'hh:mm:ss'; + } + # Whole number --> Date + elsif(int($oCell->{Val}) != $oCell->{Val}){ + $sFmtStr = 'hh:mm:ss'; + } + # Otherwise both Date and Time else { - $sFmtStr = 'm-d-yy'; - } - } - else { + $sFmtStr = 'mm-dd-yyyy hh:mm:ss'; + } + } + elsif($oCell->{Type} eq 'Time') + { + if($oCell->{Format}) + { + $sFmtStr=$oCell->{Format}; + } + elsif(int($oCell->{Val}) <= 0) + { + $sFmtStr = 'hh:mm:ss'; + } + } + else + { $sFmtStr = '@'; - } - } + } + } return $sFmtStr; } #------------------------------------------------------------------------------ Modified: trunk/gdata/inst/perl/Spreadsheet/XLSX.pm =================================================================== --- trunk/gdata/inst/perl/Spreadsheet/XLSX.pm 2010-01-24 05:36:58 UTC (rev 1390) +++ trunk/gdata/inst/perl/Spreadsheet/XLSX.pm 2010-01-24 07:26:58 UTC (rev 1391) @@ -60,7 +60,8 @@ my $formatCode = $1 || ''; if ($formatCode eq $default || not($formatCode)){ if ($t1 == 9 || $t1==10){ $formatCode="0.00000%";} - elsif ($t1 == 14){ $formatCode="m-d-yy";} + elsif ($t1 == 14){ $formatCode="yyyy-mm-dd";} + elsif ($t1 == 20){ $formatCode="h:mm";} else { $formatCode=""; } @@ -159,7 +160,7 @@ $s = m/t=\"s\"/ ? 1 : 0; $s2 = m/t=\"str\"/ ? 1 : 0; - $sty = m/s="([0-9]+)"/ ? $1 : 0; + $sty = m/s="([0-9]+)"/ ? $1 : 0; } elsif (/^<v/) { Modified: trunk/gdata/inst/perl/xls2csv.pl =================================================================== --- trunk/gdata/inst/perl/xls2csv.pl 2010-01-24 05:36:58 UTC (rev 1390) +++ trunk/gdata/inst/perl/xls2csv.pl 2010-01-24 07:26:58 UTC (rev 1391) @@ -2,11 +2,13 @@ BEGIN { use File::Basename; -unshift(@INC, dirname $0); +# Add current path to perl library search path +use lib dirname($0); } use strict; use Spreadsheet::ParseExcel; +use Spreadsheet::XLSX; use POSIX; use File::Spec::Functions; @@ -111,19 +113,32 @@ ## open spreadsheet ## -my $oExcel = new Spreadsheet::ParseExcel; +my $oExcel; +my $oBook; +$oExcel = new Spreadsheet::ParseExcel; + open(FH, "<$ARGV[0]") or die "Unable to open file '$ARGV[0]'.\n"; close(FH); print "Loading '$ARGV[0]'...\n"; -my $oBook = $oExcel->Parse($ARGV[0]) or die "Error parsing file '$ARGV[0]'.\n"; + +## First try as a Excel 2007+ 'xml' file +eval + { + local $SIG{__WARN__} = sub {}; + $oBook = Spreadsheet::XLSX -> new ($ARGV[0]); + }; +if($@) + { + $oBook = new Spreadsheet::ParseExcel->Parse($ARGV[0]) or \ + die "Error parsing file '$ARGV[0]'.\n"; + } print "Done.\n"; print "\n"; -print "Orignal Filename: ", $oBook->{File} , "\n"; +print "Orignal Filename: ", $ARGV[0], "\n"; print "Number of Sheets: ", $oBook->{SheetCount} , "\n"; -print "Author : ", $oBook->{Author} , "\n"; print "\n"; ## Get list all worksheets in the file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ggr...@us...> - 2010-01-24 02:28:18
|
Revision: 1389 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1389&view=rev Author: ggrothendieck2 Date: 2010-01-24 02:28:11 +0000 (Sun, 24 Jan 2010) Log Message: ----------- added sheetNames.Rd (documenting sheetNames/sheetCount) and updated NAMESPACE file. Modified Paths: -------------- trunk/gdata/NAMESPACE Added Paths: ----------- trunk/gdata/man/sheetNames.Rd Modified: trunk/gdata/NAMESPACE =================================================================== --- trunk/gdata/NAMESPACE 2010-01-24 02:05:51 UTC (rev 1388) +++ trunk/gdata/NAMESPACE 2010-01-24 02:28:11 UTC (rev 1389) @@ -24,6 +24,8 @@ remove.vars, reorder.factor, resample, + sheetCount, + sheetNames, trim, trimSum, unmatrix, Added: trunk/gdata/man/sheetNames.Rd =================================================================== --- trunk/gdata/man/sheetNames.Rd (rev 0) +++ trunk/gdata/man/sheetNames.Rd 2010-01-24 02:28:11 UTC (rev 1389) @@ -0,0 +1,42 @@ +\name{sheetNames} +\Rdversion{1.1} +\alias{sheetCount} +\alias{sheetNames} +\title{ +Count sheets in Excel xls spreadsheet. +} +\description{ +Count the sheets in an Excel xls spreadsheet. +} +\usage{ +sheetCount(xls, verbose = FALSE, perl = "perl") +sheetNames(xls, verbose = FALSE, perl = "perl") +} +%- maybe also 'usage' for other objects documented here. +\arguments{ + \item{xls}{ +File path to spreadsheet. Is downloaded if it begins with \code{"http://"}.} + \item{verbose}{ + If \code{TRUE} additional information displayed. +} + \item{perl}{ + Path and file of perl interpreter or just \code{"perl"} if perl on path. +} +} +\value{ +\code{sheetCount} returns the number of sheets in the spreadsheet +and \code{sheetNames} returns +a character vector containing the sheet names in the spreadsheet. +} + +\seealso{ + \code{\link{read.xls}}, \code{\link{xls2csv}}. +} +\examples{ + xlsfile <- system.file("xls", "iris.xls", package = "gdata") + xlsfile + + sheetCount(xlsfile) + +} +\keyword{ misc } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ggr...@us...> - 2010-01-24 02:05:58
|
Revision: 1388 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1388&view=rev Author: ggrothendieck2 Date: 2010-01-24 02:05:51 +0000 (Sun, 24 Jan 2010) Log Message: ----------- fixed spacing problem in NEWS Modified Paths: -------------- trunk/gdata/inst/NEWS Modified: trunk/gdata/inst/NEWS =================================================================== --- trunk/gdata/inst/NEWS 2010-01-23 07:11:46 UTC (rev 1387) +++ trunk/gdata/inst/NEWS 2010-01-24 02:05:51 UTC (rev 1388) @@ -200,7 +200,7 @@ - DESCRIPTION: Added Suggests field - - Updated the example in frameApply +- Updated the example in frameApply CHANGES IN GDATA 2.0.8 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2010-01-23 07:11:55
|
Revision: 1387 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1387&view=rev Author: warnes Date: 2010-01-23 07:11:46 +0000 (Sat, 23 Jan 2010) Log Message: ----------- Check if parsing the xls file succeeds... Current code doesn't handle new XML-based format Modified Paths: -------------- trunk/gdata/inst/perl/xls2csv.pl Modified: trunk/gdata/inst/perl/xls2csv.pl =================================================================== --- trunk/gdata/inst/perl/xls2csv.pl 2010-01-23 07:09:08 UTC (rev 1386) +++ trunk/gdata/inst/perl/xls2csv.pl 2010-01-23 07:11:46 UTC (rev 1387) @@ -117,7 +117,7 @@ close(FH); print "Loading '$ARGV[0]'...\n"; -my $oBook = $oExcel->Parse($ARGV[0]); +my $oBook = $oExcel->Parse($ARGV[0]) or die "Error parsing file '$ARGV[0]'.\n"; print "Done.\n"; print "\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2010-01-23 07:09:14
|
Revision: 1386 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1386&view=rev Author: warnes Date: 2010-01-23 07:09:08 +0000 (Sat, 23 Jan 2010) Log Message: ----------- Remove perl 'Spreadsheet:XLSX' module since it depends on Compress-Raw-Zlib, which probably won't be available on most machines, and I don't have time to figure out how to get R to build it properly when gdata is installed. Removed Paths: ------------- trunk/gdata/inst/perl/Spreadsheet/XLSX/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2010-01-23 05:51:53
|
Revision: 1384 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1384&view=rev Author: warnes Date: 2010-01-23 05:51:47 +0000 (Sat, 23 Jan 2010) Log Message: ----------- Add xls2tsv() convenience wrapper to xls2sep() Modified Paths: -------------- trunk/gdata/R/xls2sep.R Modified: trunk/gdata/R/xls2sep.R =================================================================== --- trunk/gdata/R/xls2sep.R 2010-01-23 05:50:10 UTC (rev 1383) +++ trunk/gdata/R/xls2sep.R 2010-01-23 05:51:47 UTC (rev 1384) @@ -8,6 +8,10 @@ xls2sep(xls=xls, sheet=sheet, verbose=verbose, ..., method="tab", perl=perl) +xls2tsv <- function(xls, sheet=1, verbose=FALSE, ..., perl="perl") + xls2sep(xls=xls, sheet=sheet, verbose=verbose, ..., method="tsv", + perl=perl) + xls2sep <- function(xls, sheet = 1, verbose=FALSE, ..., method=c("csv","tsv","tab"), perl="perl") { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2010-01-23 05:50:16
|
Revision: 1383 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1383&view=rev Author: warnes Date: 2010-01-23 05:50:10 +0000 (Sat, 23 Jan 2010) Log Message: ----------- Update to match new xls2csv.pl code, allow specification of sheets by name, support CSV and TAB delimited files using the same code, other minor changes. Modified Paths: -------------- trunk/gdata/R/read.xls.R trunk/gdata/R/xls2sep.R Modified: trunk/gdata/R/read.xls.R =================================================================== --- trunk/gdata/R/read.xls.R 2010-01-23 05:45:13 UTC (rev 1382) +++ trunk/gdata/R/read.xls.R 2010-01-23 05:50:10 UTC (rev 1383) @@ -1,7 +1,7 @@ ## s$Id$ read.xls <- function(xls, sheet = 1, verbose=FALSE, pattern, ..., - method=c("csv","tab"), perl="perl") + method=c("csv","tsv","tab"), perl="perl") { con <- tfn <- NULL on.exit({ @@ -15,13 +15,8 @@ xls <- path.expand(xls) - ## translate from xls to csv/tab format (returns csv file name) - if(method=="csv") - con <- xls2csv(xls, sheet, verbose=verbose, ..., perl = perl) - else if(method=="tab") - con <- xls2tab(xls, sheet, verbose=verbose, ..., perl = perl) - else - stop("Unknown method", method) + ## translate from xls to csv/tsv/tab format (returns name of created file) + con <- xls2sep(xls, sheet, verbose=verbose, ..., method=method, perl = perl) ## load the csv file open(con) @@ -35,7 +30,7 @@ if(method=="csv") retval <- read.csv(con, ...) - else if (method=="tab") + else if (method %in% c("tsv","tab") ) retval <- read.delim(con, ...) else stop("Unknown method", method) @@ -60,7 +55,7 @@ if(method=="csv") retval <- read.csv(con, skip = idx[1]-1, ...) - else if (method=="tab") + else if (method %in% c("tsv","tab") ) retval <- read.delim(con, skip = idx[1]-1, ...) else stop("Unknown method", method) Modified: trunk/gdata/R/xls2sep.R =================================================================== --- trunk/gdata/R/xls2sep.R 2010-01-23 05:45:13 UTC (rev 1382) +++ trunk/gdata/R/xls2sep.R 2010-01-23 05:50:10 UTC (rev 1383) @@ -9,7 +9,7 @@ perl=perl) xls2sep <- function(xls, sheet = 1, verbose=FALSE, ..., - method=c("csv","tab"), perl="perl") + method=c("csv","tsv","tab"), perl="perl") { method <- match.arg(method) @@ -51,6 +51,11 @@ script <- file.path(perl.dir,'xls2tab.pl') targetFile <- paste(tempfile(), "tab", sep = ".") } + else if(method=="tsv") + { + script <- file.path(perl.dir,'xls2tsv.pl') + targetFile <- paste(tempfile(), "tsv", sep = ".") + } else { stop("Unknown method", method) @@ -89,7 +94,7 @@ ## if(file.access(targetFile, 4)!=0) - stop("Unable to read translated", method, "file '", targetFile, "'." ) + stop("Unable to read translated ", method, " file '", targetFile, "'." ) cat("Done.\n") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2010-01-23 05:45:19
|
Revision: 1382 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1382&view=rev Author: warnes Date: 2010-01-23 05:45:13 +0000 (Sat, 23 Jan 2010) Log Message: ----------- Add sheetNames() function to extract the names from XLS files Modified Paths: -------------- trunk/gdata/R/sheetCount.R Modified: trunk/gdata/R/sheetCount.R =================================================================== --- trunk/gdata/R/sheetCount.R 2010-01-23 05:23:22 UTC (rev 1381) +++ trunk/gdata/R/sheetCount.R 2010-01-23 05:45:13 UTC (rev 1382) @@ -1,4 +1,10 @@ sheetCount <- function(xls, verbose = FALSE, perl = "perl") + sheetCmd(xls, cmd="sheetCount.pl", verbose=verbose, perl=perl) + +sheetNames <- function(xls, verbose = FALSE, perl = "perl") + sheetCmd(xls, cmd="sheetNames.pl", verbose=verbose, perl=perl) + +sheetCmd <- function(xls, cmd="sheetCount.pl", verbose=FALSE, perl="perl") { ## @@ -27,7 +33,7 @@ } ## - sc <- file.path(perl.dir,'sheetCount.pl') + sc <- file.path(perl.dir, cmd) ## ## @@ -49,10 +55,14 @@ } ## results <- system(cmd, intern=TRUE) + tc <- textConnection(results) + results <- read.table(tc, as.is=TRUE, header=FALSE) + results <- unlist(results) + names(results) <- NULL ## if (verbose) cat("Done.\n\n") - as.numeric(results) + results } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2010-01-23 05:23:28
|
Revision: 1381 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1381&view=rev Author: warnes Date: 2010-01-23 05:23:22 +0000 (Sat, 23 Jan 2010) Log Message: ----------- Fix xls2csv.bat Modified Paths: -------------- trunk/gdata/inst/bin/xls2csv.bat Modified: trunk/gdata/inst/bin/xls2csv.bat =================================================================== --- trunk/gdata/inst/bin/xls2csv.bat 2010-01-23 05:17:20 UTC (rev 1380) +++ trunk/gdata/inst/bin/xls2csv.bat 2010-01-23 05:23:22 UTC (rev 1381) @@ -1,168 +1,3 @@ -#!/bin/env perl - -BEGIN { -use File::Basename; -unshift(@INC, dirname $0); -} - -use strict; -use Spreadsheet::ParseExcel; - -# declare some varibles local -my($row, $col, $sheet, $cell, $usage, $basename, $sheetnumber, $filename); - -## -## Usage information -## -$usage = <<EOF; - -xls2csv.pl <excel file> [<output file>] [<worksheet number>] - -Translate the Microsoft Excel spreadsheet file contained in -<excel file> into comma separated value format (CSV) and store -in <output file>. - -If <output file> is not specified, the output file will have the -same name as the input file with '.xls' or '.XLS' (if any) -removed and '.csv' appended. - -If no worksheet number is given, each worksheet will be written to -a separate file with the name '<output file>_<worksheet name>.csv'. - -EOF - -## -## parse arguments -## - -if(!defined($ARGV[0])) - { - print $usage; - exit 1; - } - -$basename = $ARGV[1]; -$basename =~ s/.csv//; -if ($basename eq "") - { - my @path; - @path = split(/[\/\\]/, $ARGV[0]); # split on file separator - $basename = $path[$#path]; - $basename =~ s/.xls//i; - } - -if(defined($ARGV[2]) ) - { - $sheetnumber = $ARGV[2]; - die "Sheetnumber must be an integer larger than 0." if $sheetnumber < 1; - } - -## -## open spreadsheet -## - -my $oExcel = new Spreadsheet::ParseExcel; - -print "Loading $ARGV[0] ...\n"; - -open(FH, "<$ARGV[0]") or die "Unable to open file '$ARGV[0]'.\n"; -close(FH); - -my $oBook = $oExcel->Parse($ARGV[0]); - -print "\n"; -print "Orignal Filename :", $oBook->{File} , "\n"; -print "Number of Sheets :", $oBook->{SheetCount} , "\n"; -print "Author :", $oBook->{Author} , "\n"; -print "\n"; - -my @sheetlist = (@{$oBook->{Worksheet}}); -if (defined($sheetnumber)) - { - @sheetlist=($sheetlist[$sheetnumber-1]); - } - -## -## iterate across each worksheet, writing out a separat csv file -## - -my $i=0; -foreach my $sheet (@sheetlist) -{ - $i++; - - my $sheetname = $sheet->{Name}; - if(defined($sheetnumber)) - { - $filename = "${basename}.csv"; - } - else - { - $filename = "${basename}_${sheetname}.csv"; - } - - print "Writing Sheet number $i ('$sheetname') to file '$filename'\n"; - - open(OutFile,">$filename"); - - my $cumulativeBlankLines=0; - - my $minrow = $sheet->{MinRow}; - my $maxrow = $sheet->{MaxRow}; - my $mincol = $sheet->{MinCol}; - my $maxcol = $sheet->{MaxCol}; - - print "Minrow=$minrow Maxrow=$maxrow Mincol=$mincol Maxcol=$maxcol\n"; - - for(my $row = $minrow; $row <= $maxrow; $row++) - { - my $outputLine = ""; - - for(my $col = $mincol; $col <= $maxcol; $col++) - { - my $cell = $sheet->{Cells}[$row][$col]; - if( defined($cell) ) - { - $_=$cell->Value; #{Val}; - - # convert '#NUM!' strings to missing (empty) values - s/#NUM!//; - - # escape double-quote characters in the data since - # they are used as field delimiters - s/\"/\\\"/g; - } - else - { - $_ = ''; - } - - $outputLine .= "\"" . $_ . "\"" if(length($_)>0); - - # separate cells with commas - $outputLine .= "," if( $col != $maxcol) ; - - } - - #$outputLine =~ s/[, ]+$//g; ## strip off trailing blanks and commas - - # skip blank/empty lines - if( $outputLine =~ /^[, ]*$/ ) - { - $cumulativeBlankLines++ - } - else - { - print OutFile "$outputLine \n" - } - } - - close OutFile; - - print " (Ignored $cumulativeBlankLines blank lines.)\n" - if ($cumulativeBlankLines); - print "\n"; -} - - - +REM @echo off +SET PERLPATH= %~dp0\..\perl\ +perl %PERLPATH%\xls2csv.pl %* This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2010-01-23 05:17:26
|
Revision: 1380 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1380&view=rev Author: warnes Date: 2010-01-23 05:17:20 +0000 (Sat, 23 Jan 2010) Log Message: ----------- If only one sheet is present in the file, don't insert the sheet name into the filename Modified Paths: -------------- trunk/gdata/inst/perl/xls2csv.pl Modified: trunk/gdata/inst/perl/xls2csv.pl =================================================================== --- trunk/gdata/inst/perl/xls2csv.pl 2010-01-23 04:38:31 UTC (rev 1379) +++ trunk/gdata/inst/perl/xls2csv.pl 2010-01-23 05:17:20 UTC (rev 1380) @@ -158,7 +158,7 @@ $sheetname = $sheet->{Name}; - if( defined($sheetnumber) || defined($targetsheetname) ) + if( defined($sheetnumber) || defined($targetsheetname) || $oBook->{SheetCount}==1 ) { if( defined($targetfile) ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2010-01-23 04:38:37
|
Revision: 1379 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1379&view=rev Author: warnes Date: 2010-01-23 04:38:31 +0000 (Sat, 23 Jan 2010) Log Message: ----------- Add additional test/example Excel files Added Paths: ----------- trunk/gdata/inst/xls/ExampleExcelFile.xls trunk/gdata/inst/xls/ExampleExcelFile.xlsx Added: trunk/gdata/inst/xls/ExampleExcelFile.xls =================================================================== (Binary files differ) Property changes on: trunk/gdata/inst/xls/ExampleExcelFile.xls ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/gdata/inst/xls/ExampleExcelFile.xlsx =================================================================== (Binary files differ) Property changes on: trunk/gdata/inst/xls/ExampleExcelFile.xlsx ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <wa...@us...> - 2010-01-23 04:35:00
|
Revision: 1378 http://r-gregmisc.svn.sourceforge.net/r-gregmisc/?rev=1378&view=rev Author: warnes Date: 2010-01-23 04:34:54 +0000 (Sat, 23 Jan 2010) Log Message: ----------- Modify xls2csv.pl script to: - Use tab-delimiter and .tsv or .tab extension if called with the name xls2tsv.pl or xls2tab.pl, respectively. This allows a single source file and two symlinks to be used intstead of maintaining several almost-identical files. - Allow selection of sheets by name - Provide better error checking - Other code improvements Modified Paths: -------------- trunk/gdata/inst/perl/xls2csv.pl Added Paths: ----------- trunk/gdata/inst/perl/xls2tab.pl trunk/gdata/inst/perl/xls2tsv.pl Removed Paths: ------------- trunk/gdata/inst/perl/xls2tab.pl Modified: trunk/gdata/inst/perl/xls2csv.pl =================================================================== --- trunk/gdata/inst/perl/xls2csv.pl 2010-01-23 02:30:09 UTC (rev 1377) +++ trunk/gdata/inst/perl/xls2csv.pl 2010-01-23 04:34:54 UTC (rev 1378) @@ -1,4 +1,4 @@ -#!/bin/env perl +#!/usr/bin/perl BEGIN { use File::Basename; @@ -7,27 +7,66 @@ use strict; use Spreadsheet::ParseExcel; +use POSIX; +use File::Spec::Functions; # declare some varibles local -my($row, $col, $sheet, $cell, $usage, $basename, $sheetnumber, $filename); +my($row, $col, $sheet, $cell, $usage, + $targetfile,$basename, $sheetnumber, + $filename, $volume, $directories, $whoami, + $sep, $sepName, $sepLabel, $sepExt); + ## +## Figure out whether I'm called as xls2csv.pl or xls2tab.pl +## +($volume,$directories,$whoami) = File::Spec->splitpath( $0 ); + +if($whoami eq "xls2csv.pl") + { + $sep=","; + $sepName="comma"; + $sepLabel="CSV"; + $sepExt="csv"; + + } +elsif ($whoami eq "xls2tsv.pl") + { + $sep="\t"; + $sepName="tab"; + $sepLabel="TSV"; + $sepExt="tsv"; + } +elsif ($whoami eq "xls2tab.pl") + { + $sep="\t"; + $sepName="tab"; + $sepLabel="TAB"; + $sepExt="tab"; + } +else + { + die("This script is named '$whoami', but must be named either 'xls2csv.pl' or 'xls2tab.pl' to function properly.\n"); + } + + +## ## Usage information ## $usage = <<EOF; -xls2csv.pl <excel file> [<output file>] [<worksheet number>] +$whoami <excel file> [<output file>] [<worksheet number>] Translate the Microsoft Excel spreadsheet file contained in -<excel file> into comma separated value format (CSV) and store -in <output file>. +<excel file> into $sepName separated value format ($sepLabel) and +store in <output file>. -If <output file> is not specified, the output file will have the -same name as the input file with '.xls' or '.XLS' (if any) -removed and '.csv' appended. +If <output file> is not specified, the output file will have the same +name as the input file with '.xls', or 'xlsx' removed and '.$sepExt' +appended. If no worksheet number is given, each worksheet will be written to -a separate file with the name '<output file>_<worksheet name>.csv'. +a separate file with the name '<output file>_<worksheet name>.$sepExt'. EOF @@ -35,26 +74,37 @@ ## parse arguments ## -if(!defined($ARGV[0])) +if( !defined($ARGV[0]) ) { print $usage; exit 1; } -$basename = $ARGV[1]; -$basename =~ s/.csv//; -if ($basename eq "") - { - my @path; - @path = split(/[\/\\]/, $ARGV[0]); # split on file separator - $basename = $path[$#path]; - $basename =~ s/.xls//i; - } +if( defined($ARGV[1]) ) + { + $basename = $targetfile = $ARGV[1]; + $basename =~ s/\.$sepExt$//i; + } +else + { + ($volume,$directories,$basename) = File::Spec->splitpath( $ARGV[0] ); + $basename =~ s/\.xlsx*//i; + } +my $targetsheetname; +my $sheetnumber; + if(defined($ARGV[2]) ) { - $sheetnumber = $ARGV[2]; - die "Sheetnumber must be an integer larger than 0." if $sheetnumber < 1; + if ( isdigit($ARGV[2]) ) + { + $sheetnumber = $ARGV[2]; + die "Sheetnumber must be an integer larger than 0.\n" if $sheetnumber < 1; + } + else + { + $targetsheetname = $ARGV[2]; + } } ## @@ -63,45 +113,79 @@ my $oExcel = new Spreadsheet::ParseExcel; -print "Loading $ARGV[0] ...\n"; - open(FH, "<$ARGV[0]") or die "Unable to open file '$ARGV[0]'.\n"; close(FH); +print "Loading '$ARGV[0]'...\n"; my $oBook = $oExcel->Parse($ARGV[0]); +print "Done.\n"; print "\n"; -print "Orignal Filename :", $oBook->{File} , "\n"; -print "Number of Sheets :", $oBook->{SheetCount} , "\n"; -print "Author :", $oBook->{Author} , "\n"; +print "Orignal Filename: ", $oBook->{File} , "\n"; +print "Number of Sheets: ", $oBook->{SheetCount} , "\n"; +print "Author : ", $oBook->{Author} , "\n"; print "\n"; +## Get list all worksheets in the file my @sheetlist = (@{$oBook->{Worksheet}}); -if (defined($sheetnumber)) +my $sheet; + +## If we want a specific sheet drop everything else +if ( defined($sheetnumber) ) { - @sheetlist=($sheetlist[$sheetnumber-1]); + $sheet = $oBook->Worksheet($sheetnumber-1) or die "No sheet number $sheetnumber.\n"; + @sheetlist = ( $sheet ); + } +elsif ( defined($targetsheetname) ) + { + $sheet = $oBook->Worksheet($targetsheetname) or die "No sheet named '$targetsheetname'.\n"; + @sheetlist = ( $sheet ); + } + ## ## iterate across each worksheet, writing out a separat csv file ## my $i=0; +my $sheetname; +my $found=0; foreach my $sheet (@sheetlist) { $i++; - my $sheetname = $sheet->{Name}; - if(defined($sheetnumber)) + + $sheetname = $sheet->{Name}; + + if( defined($sheetnumber) || defined($targetsheetname) ) { - $filename = "${basename}.csv"; + if( defined($targetfile) ) + { + $filename = $targetfile; + } + else + { + $filename = "${basename}.$sepExt"; + } } else { - $filename = "${basename}_${sheetname}.csv"; + $filename = "${basename}_${sheetname}.$sepExt"; } - print "Writing Sheet number $i ('$sheetname') to file '$filename'\n"; + if( defined($sheetnumber) ) + { + print "Writing sheet number $sheetnumber ('$sheetname') to file '$filename'\n"; + } + elsif ( defined($targetsheetname) ) + { + print "Writing sheet '$sheetname' to file '$filename'\n"; + } + else + { + print "Writing sheet number $i ('$sheetname') to file '$filename'\n"; + } open(OutFile,">$filename"); @@ -139,15 +223,13 @@ $outputLine .= "\"" . $_ . "\"" if(length($_)>0); - # separate cells with commas - $outputLine .= "," if( $col != $maxcol) ; + # separate cells with specified separator + $outputLine .= $sep if( $col != $maxcol) ; } - #$outputLine =~ s/[, ]+$//g; ## strip off trailing blanks and commas - # skip blank/empty lines - if( $outputLine =~ /^[, ]*$/ ) + if( $outputLine =~ /^[$sep ]*$/ ) { $cumulativeBlankLines++ } Deleted: trunk/gdata/inst/perl/xls2tab.pl =================================================================== --- trunk/gdata/inst/perl/xls2tab.pl 2010-01-23 02:30:09 UTC (rev 1377) +++ trunk/gdata/inst/perl/xls2tab.pl 2010-01-23 04:34:54 UTC (rev 1378) @@ -1,166 +0,0 @@ -#!/bin/env perl - -BEGIN { -use File::Basename; -unshift(@INC, dirname $0); -} - -use strict; -use Spreadsheet::ParseExcel; - -# declare some varibles local -my($row, $col, $sheet, $cell, $usage, $basename, $sheetnumber, $filename); - -## -## Usage information -## -$usage = <<EOF; - -xls2tab.pl <excel file> [<output file>] [<worksheet number>] - -Translate the Microsoft Excel spreadsheet file contained in -<excel file> into tab separated value format (TAB) and store -in <output file>. - -If <output file> is not specified, the output file will have the -same name as the input file with '.xls' or '.XLS' (if any) -removed and '.tab' appended. - -If no worksheet number is given, each worksheet will be written to -a separate file with the name '<output file>_<worksheet name>.tab'. - -EOF - -## -## parse arguments -## - -if(!defined($ARGV[0])) - { - print $usage; - exit 1; - } - -$basename = $ARGV[1]; -$basename =~ s/.tab//; -if ($basename eq "") - { - my @path; - @path = split(/[\/\\]/, $ARGV[0]); # split on file separator - $basename = $path[$#path]; - $basename =~ s/.xls//i; - } - -if(defined($ARGV[2]) ) - { - $sheetnumber = $ARGV[2]; - die "Sheetnumber must be an integer larger than 0." if $sheetnumber < 1; - } - -## -## open spreadsheet -## - -my $oExcel = new Spreadsheet::ParseExcel; - -print "Loading $ARGV[0] ...\n"; - -open(FH, "<$ARGV[0]") or die "Unable to open file '$ARGV[0]'.\n"; -close(FH); - -my $oBook = $oExcel->Parse($ARGV[0]); - -print "\n"; -print "Orignal Filename :", $oBook->{File} , "\n"; -print "Number of Sheets :", $oBook->{SheetCount} , "\n"; -print "Author :", $oBook->{Author} , "\n"; -print "\n"; - -my @sheetlist = (@{$oBook->{Worksheet}}); -if (defined($sheetnumber)) - { - @sheetlist=($sheetlist[$sheetnumber-1]); - } - -## -## iterate across each worksheet, writing out a separat tab file -## - -my $i=0; -foreach my $sheet (@sheetlist) -{ - $i++; - - my $sheetname = $sheet->{Name}; - if(defined($sheetnumber)) - { - $filename = "${basename}.tab"; - } - else - { - $filename = "${basename}_${sheetname}.tab"; - } - - print "Writing Sheet number $i ('$sheetname') to file '$filename'\n"; - - open(OutFile,">$filename"); - - my $cumulativeBlankLines=0; - - my $minrow = $sheet->{MinRow}; - my $maxrow = $sheet->{MaxRow}; - my $mincol = $sheet->{MinCol}; - my $maxcol = $sheet->{MaxCol}; - - print "Minrow=$minrow Maxrow=$maxrow Mincol=$mincol Maxcol=$maxcol\n"; - - for(my $row = $minrow; $row <= $maxrow; $row++) - { - my $outputLine = ""; - - for(my $col = $mincol; $col <= $maxcol; $col++) - { - my $cell = $sheet->{Cells}[$row][$col]; - if( defined($cell) ) - { - $_=$cell->Value; #{Val}; - - # convert '#NUM!' strings to missing (empty) values - s/#NUM!//; - - # escape double-quote characters in the data since - # they are used as field delimiters - s/\"/\\\"/g; - } - else - { - $_ = ''; - } - - $outputLine .= "\"" . $_ . "\"" if(length($_)>0); - - # separate cells with tabs - $outputLine .= "\t" if( $col != $maxcol) ; - - } - - #$outputLine =~ s/[\t ]+$//g; ## strip off trailing blanks and tabs - - # skip blank/empty lines - if( $outputLine =~ /^[\t ]*$/ ) - { - $cumulativeBlankLines++ - } - else - { - print OutFile "$outputLine \n" - } - } - - close OutFile; - - print " (Ignored $cumulativeBlankLines blank lines.)\n" - if ($cumulativeBlankLines); - print "\n"; -} - Added: trunk/gdata/inst/perl/xls2tab.pl =================================================================== --- trunk/gdata/inst/perl/xls2tab.pl (rev 0) +++ trunk/gdata/inst/perl/xls2tab.pl 2010-01-23 04:34:54 UTC (rev 1378) @@ -0,0 +1 @@ +link xls2csv.pl \ No newline at end of file Property changes on: trunk/gdata/inst/perl/xls2tab.pl ___________________________________________________________________ Added: svn:special + * Added: trunk/gdata/inst/perl/xls2tsv.pl =================================================================== --- trunk/gdata/inst/perl/xls2tsv.pl (rev 0) +++ trunk/gdata/inst/perl/xls2tsv.pl 2010-01-23 04:34:54 UTC (rev 1378) @@ -0,0 +1 @@ +link xls2csv.pl \ No newline at end of file Property changes on: trunk/gdata/inst/perl/xls2tsv.pl ___________________________________________________________________ Added: svn:special + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |