Re: [R] Loading mdb

From: Kenn Konstabel <>
Date: Tue, 22 Mar 2011 21:09:25 +0000

I've used RODBC to read in ms access files... or if you're as lazy as me you could use the following below (it can handle some other ms office file types too and thinks it can recognize file types but as has been pointed out in this list, using it with excel probably means trouble)

read.mso <- function(fail, sheet="Sheet1$", browse=FALSE, tables=FALSE, FUN = NULL, ...){

    # require(RODBC)
    # require(utils)
    # 'fail' is Estonian for 'file', don't be confused :)
    whence <- strsplit(basename(fail), "\\.")[[1]][2]     if(is.null(FUN)) FUN <- switch(whence, xls=odbcConnectExcel,
                mdb=odbcConnectAccess, xlsx=odbcConnectExcel2007,
                accdb=odbcConnectAccess2007, dbf=odbcConnectDbase,

    con <- FUN(fail)
    if(browse) browser()
    res <- if(tables) sqlTables(con) else sqlFetch(con, sheet, ...)     close(con)

# lists tables with TABLE=TRUE, otherwise sqlFetch'es the table named in "sheet"

On Tue, Mar 22, 2011 at 5:05 PM, LCOG1 <> wrote:
> Well im thoroughly frustrated after 25 minutes of checking and rechecking my
> path.  What do i not know about loading a mdb that is keeping me from
> loading my data.
> i have loaded the Hmisc library and pointed it too my data using mdb.get and
> continue to get the following error.
> Error in system(paste("mdb-tables -1", file), intern = TRUE) :
>  'mdb-tables' not found
> Which i realize is saying that its not reading any tables within the mdb or
> not able to find any mdb at all at that location.
> the command i use is simply:
> There is definitely a mdb in that location and the path is definitely
> correct.  Its an MS Access mdb with 4 tables.  When i open the said mdb i
> have to hit enter at a password window but no password is required.  Could
> this be hanging up R from reading it?  I have typically used dbf and csv or
> txt for import formats and am not real familiar with mdb but i realize how
> elementary this question is but i have spent 25 minutes now.  What am i
> missing.
> Thanks
> JR
> --
> View this message in context:
> Sent from the R help mailing list archive at
> ______________________________________________
> mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code. mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Tue 22 Mar 2011 - 21:15:27 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 22 Mar 2011 - 21:20:24 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive