Link to home
Start Free TrialLog in
Avatar of AddOnsInc
AddOnsInc

asked on

Reading CSV file with ODBC Text Driver and Retain Field Format

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?
Avatar of leonstryker
leonstryker
Flag of United States of America image

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

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbcjetschema_ini_file.asp

Leon
ASKER CERTIFIED SOLUTION
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Please take the time to re-read the EE Guidelines regarding grading at:
What's the right grade to give?
https://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/VB_Databases/help.jsp#hi73

And in particular this section:
<quote>
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.

</quote>

Also this link:

Can I get a grade changed?
https://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/VB_Databases/help.jsp#hs5
Do you have any comments?