Skip to content

Reading Text Files with RODBC

4 messages · Nutter, Benjamin, Gabor Grothendieck, Jeff Newmiller

#
I'm thoroughly stumped.  I've been playing with RODBC and wanted to see if I could retrieve data from text files using this package as well (for the most part, this is an intellectual exercise, but occasionally I do get data files large enough in CSV format RODBC could be helpful) .

I set up a DNS called "Text Files" and then ran the following code in R
TABLE_CAT TABLE_SCHEM    TABLE_NAME  TABLE_TYPE        REMARKS
1 C:\\USERS\\NUTTERB                   <NA>    Core2012.txt              TABLE                 <NA>
2 C:\\USERS\\NUTTERB                   <NA> MTGCards.csv              TABLE                 <NA>
Error in odbcTableExists(channel, sqtable) : 
  'MTGCards.csv': table not found on channel
MTGCards.csv is an export from an MS Access database, and I'm able to get it out of Access, and I'm also able to connect to our Oracle databases.  So I'm not sure what it is I'm not getting about reading the text files.  If anyone has done this successfully and has any pointers, I'd appreciate it.  So far I've not been able to solve it with documentation from RODBC, RStudio (I get the same error messages when I use the RGui), or Microsoft ODBC drivers.

Windows 7, 32 bit
R 2.14.1
RODBC 1.3-4
RStudio Version 3



? Benjamin Nutter |??Biostatistician?    |??Quantitative Health Sciences
? Cleveland Clinic  ? | ?9500 Euclid Ave.? | ?Cleveland, OH 44195? |?(216) 445-1365



===================================

 Please consider the environment before printing this e-mail

Cleveland Clinic is ranked one of the top hospitals
in America by U.S.News & World Report (2010).  
Visit us online at http://www.clevelandclinic.org for
a complete listing of our services, staff and
locations.


Confidentiality Note:  This message is intended for use
only by the individual or entity to which it is addressed
and may contain information that is privileged,
confidential, and exempt from disclosure under applicable
law.  If the reader of this message is not the intended
recipient or the employee or agent responsible for
delivering the message to the intended recipient, you are
hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited.  If
you have received this communication in error,  please
contact the sender immediately and destroy the material in
its entirety, whether electronic or hard copy.  Thank you.
#
On Thu, Feb 16, 2012 at 10:12 AM, Nutter, Benjamin <NutterB at ccf.org> wrote:
This isn't precisely what you are asking for but if the idea is to
apply an sql statement to a csv file then read.csv.sql in the sqldf
package can apply an sql statement to a csv file reading the result
into R.  If you omit the sql statement then it reads it all in.
#
Ah, yes.  If you can't find the answer to your question, ask a different question!

sqldf does, indeed, do what I want.  Thank you

? Benjamin Nutter |??Biostatistician   ? |??Quantitative Health Sciences
? Cleveland Clinic?   | ?9500 Euclid Ave.? | ?Cleveland, OH 44195? |?(216) 445-1365


-----Original Message-----
From: Gabor Grothendieck [mailto:ggrothendieck at gmail.com] 
Sent: Thursday, February 16, 2012 1:15 PM
To: Nutter, Benjamin
Cc: r-help at r-project.org
Subject: Re: [R] Reading Text Files with RODBC
On Thu, Feb 16, 2012 at 10:12 AM, Nutter, Benjamin <NutterB at ccf.org> wrote:
This isn't precisely what you are asking for but if the idea is to apply an sql statement to a csv file then read.csv.sql in the sqldf package can apply an sql statement to a csv file reading the result into R.  If you omit the sql statement then it reads it all in.

--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com


===================================

 Please consider the environment before printing this e-mail

Cleveland Clinic is ranked one of the top hospitals
in America by U.S.News & World Report (2010).  
Visit us online at http://www.clevelandclinic.org for
a complete listing of our services, staff and
locations.


Confidentiality Note:  This message is intended for use\...{{dropped:13}}
#
To be fair, RODBC is just an interface to ODBC, and this is not an ODBC support forum. In my experience, ODBC works alright when used to connect to a SQL database, but is pretty flaky when used to connect to Excel or CSV files.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.
"Nutter, Benjamin" <NutterB at ccf.org> wrote: