Reading CSV file with ODBC Text Driver and Retain Field Format

Posted on 2006-04-06
Last Modified: 2013-12-25
I am using the MS ODBC text driver to read a CSV file.  My logic is fairly dynaminc in that I do not know the number of fields or their format before-hand.  I would like to read the fields in as text fields so the formatting in the csv file is retained.  My problem is that I have a field that is being interpreted as a numeric field and the leading zeroes are being dropped.  For example, '0403100' is being read in as '403100'.   Again, I don't know which field in the table this will be.  I simply want to read the field in as a text field retaining all formatting in the file.  I can not save the CSV file with quotes around the fields either.  Any ideas?
Question by:AddOnsInc
    LVL 29

    Expert Comment

    You will need to create a schema.ini file and specify column data type as text.

    LVL 75

    Accepted Solution

    If you do not know the format ahead of time, consider opening the file as a standard text file and looping through all the rows.  You can then use the Split funciton to get all the values.
    LVL 75

    Expert Comment

    by:Anthony Perkins
    Please take the time to re-read the EE Guidelines regarding grading at:
    What's the right grade to give?

    And in particular this section:
    C: Because Experts' reliability are often judged by their grading records, many Experts would like the opportunity to clarify if you have questions about their solutions. If you have given the Expert(s) ample time to respond to your clarification posts and you have responded to each of their posts providing requested information; or if the answers, after clarification, lack finality or do not completely address the issue presented, then a "C" grade is an option. You also have the option here of just asking Community Support to delete the question.
    Remember, the Expert helping you today is probably going to be helping you next time you post a question. Give them a fair chance to earn an 'Excellent!' grade and they'll provide you with some amazing support. It's also true that a "C" is the lowest grade you can give, and the Experts know that -- so use it judiciously.

    ... Similarly, the C grade is the lowest that can be given by a member, a fact which should be kept in mind when grading as well.

    The use of a C in a vindictive manner is likely to be changed by a Moderator. You may not like the answer you get, and in some cases, and you may not like the way it is delivered, but if it is deemed to be accurate, no less than a B is an acceptable grade.


    Also this link:

    Can I get a grade changed?
    LVL 75

    Expert Comment

    by:Anthony Perkins
    Do you have any comments?

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Suggested Solutions

    If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now