installr
installr copied to clipboard
xlsx2csv grepl?
I'm intrigued by the xlsx2csv
function ... never thought to use VB, very interesting.
I noticed that the line to check for an expected file name seemed odd, so I tested it out. (Use of cbind
solely for quick/easy viewing.)
fn <- c("foo.xlsx", "foo.xls", "foo.xlsb", "foo.xlsm", "foo.xls.zip", "quux", "foo.docx")
cbind.data.frame(filename = fn, results = grepl("\\.xlsx || \\.xls", fn))
# filename results
#1 foo.xlsx TRUE
#2 foo.xls TRUE
#3 foo.xlsb TRUE
#4 foo.xlsm TRUE
#5 foo.xls.zip TRUE
#6 quux TRUE
#7 foo.docx TRUE
I don't think it's doing what you (I?) think it should. As an alternative, how about:
cbind.data.frame(filename = fn, results = grepl("\\.xls[xm]?$", fn) )
# filename results
#1 foo.xlsx TRUE
#2 foo.xls TRUE
#3 foo.xlsb FALSE
#4 foo.xlsm TRUE
#5 foo.xls.zip FALSE
#6 quux FALSE
#7 foo.docx FALSE
(I also suggest that .xlsm
files should also work.)