Reading Tab Delimited Data With Imbedded Double Quotes

T

Tom

I can't get the Microsoft Jet OLEDB 4.0 driver to read a tab delimited
text file that has double quotes imbedded in the data. For example

Field1 | Field2 | Field3
Bob | Pant Size 34" Waist | 22

(I'm using a vertical bar here for the tab)

Field2 will contain: Pant Size 34
Field3 will contain: Waist

I have a schema.ini

[MyFile.txt]
ColNameHeader=True
Format=TabDelimited
MaxScanRows=25
CharacterSet=OEM

How do I get it to read the double quote?

Tom
 
P

Paul Clement

¤ I can't get the Microsoft Jet OLEDB 4.0 driver to read a tab delimited
¤ text file that has double quotes imbedded in the data. For example
¤
¤ Field1 | Field2 | Field3
¤ Bob | Pant Size 34" Waist | 22
¤
¤ (I'm using a vertical bar here for the tab)
¤
¤ Field2 will contain: Pant Size 34
¤ Field3 will contain: Waist
¤
¤ I have a schema.ini
¤
¤ [MyFile.txt]
¤ ColNameHeader=True
¤ Format=TabDelimited
¤ MaxScanRows=25
¤ CharacterSet=OEM
¤
¤ How do I get it to read the double quote?

Double quotes are considered field delimiters by the Text ISAM driver. You will probably need to use
the System.IO namespace instead.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 
T

Tom

Paul said:
¤ I can't get the Microsoft Jet OLEDB 4.0 driver to read a tab delimited
¤ text file that has double quotes imbedded in the data. For example
¤
¤ Field1 | Field2 | Field3
¤ Bob | Pant Size 34" Waist | 22
¤
¤ (I'm using a vertical bar here for the tab)
¤
¤ Field2 will contain: Pant Size 34
¤ Field3 will contain: Waist
¤
¤ I have a schema.ini
¤
¤ [MyFile.txt]
¤ ColNameHeader=True
¤ Format=TabDelimited
¤ MaxScanRows=25
¤ CharacterSet=OEM
¤
¤ How do I get it to read the double quote?

Double quotes are considered field delimiters by the Text ISAM driver. You will probably need to use
the System.IO namespace instead.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)


That's pretty limiting. Access can link to the text file I'm working
with and properly parse the field with the double quote. Why can't
DotNet get to that same driver?

I assume that when you say use the System.IO namespace you mean I should
read and parse the file manually. Yikes.

Thanks
 
T

Tom

I figured it out. I wanted a way to tell the OLEDB Jet 4.0 driver to
ignore the double quote as a text delimiter. There is nothing like that
on MSDN. After 8 hours of Google newsgroup searching I found one post
that referred to a MS article that tells how.

http://support.microsoft.com/default.aspx?scid=kb;EN-US;205439

In the schema.ini file add

TextDelimiter='

where the ' is what ever character you would like it to be. In my case
the data was coming from a mainframe where they can't type a few PC
characters like the ^. I used that as the text delimiter.

Another solution was to change all occurrences of " into "". That will
cause the driver to pass it on as data rather than try to start a text
delimit scan.

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top