Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7192077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:51:52+00:00 2026-05-28T19:51:52+00:00

RODBC is the main library in R to import data from a database into

  • 0

RODBC is the main library in R to import data from a database into R. RODBC seems to have the ability of "guess" the datatype of the column which I find it particularly annoying.

I have uploaded a file test.xls here, or you may create a xls file yourself:

  1. create 2 columns, first column named col_a and the second column named col_b.
  2. type whatever you like in col_a, I typed letters on this column for 92 rows
  3. at the 92th row of col_b, type a number there, I typed "1923" without changing the data type (i.e. not using ')
  4. try to import the xls file into R using the following script:

library(RODBC)

setwd("C:/Users/hke775/Documents/Enoch/MISC/R_problems/RODBC")
channel <- odbcConnectExcel("test.xls",readOnly=TRUE)
dummy.df <- sqlFetch(channel,"Sheet1")
odbcClose(channel)

You will see that in dummy.df, col_b is all NA, the 1923 in this column is gone.

If you want to see the 1923 again, you can change the 1st row of col_b to a number, and it is back again.

This is very annoying as I don’t prefer modifying data manually. I need to use other package to do the xls importing, but I can’t find other packages do as smooth as RODBC (I tried gdata and xlsReadWrite).

Did I missing anything in the sqlFetch command, and cause the trouble? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:51:53+00:00Added an answer on May 28, 2026 at 7:51 pm

    Please don’t blame R or RODBC for Microsoft’s bugs… 😉

    However, due to a bug in the ODBC driver, specifying the Rows to Scan
    (MaxScanRows) setting currently has no effect. In other words, the
    Excel ODBC driver (MDAC 2.1 and later) always scans the first 8 rows
    in the specified data source in order to determine each column’s
    datatype.

    For additional information about the Rows to Scan bug, including a
    simple workaround, click the article number below to view the article
    in the Microsoft Knowledge Base:

    189897 XL97: Data
    Truncated to 255 Characters with Excel ODBC Driver

    I tried the fix in KB189897 by setting the TypeGuessRows value to 0 and look what happens!

    > library(RODBC)
    > channel <- odbcConnectExcel("test.xls",readOnly=TRUE)
    > tail(dummy.df <- sqlFetch(channel,"Sheet1"))
       col_a col_b
    87     c    NA
    88     d    NA
    89     e    NA
    90     f    NA
    91     g    NA
    92     h  1923
    > odbcClose(channel)
    

    Please, no up-votes or check marks… just send cash. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a data frame from a SQL query using the RODBC package.
I'm using R to read some data from a MySQL database using the RODBC
I am trying to pull data from our Oracle datamart into R using RODBC.
I am trying to load some data into R from an Access database. All
I am trying to import some data from Sql Server 2008 into R, using
I know I can use the RODBC library for accessing excel (.xls) docs from
With functionality from the RODBC package, I have successfully created an ODBC but receive
I'm trying to export data from R into one Excel file (into different sheets):
I've a question about using sqlSave. How does R map RODBC data in the
I have an Excel file that I am trying to load into R using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.