OLE DB reads a CSV file: using the specified separator symbol

Source: Internet
Author: User
Tags ole

When I read a CSV file in OLE DB today, we found that the resulting text was not usually separated by commas. Instead, tab tabs are used to separate them.

OrderID    OrderName1    3

And then went to msnd to query the existing specified Parameters for tab tab:

tabdelimited    files are used as tab-delimited files

Then try to drop the FMT set to tabdelimited, but the results are found and cannot be separated as a result. It seems that Microsoft's document pits or their own understanding may be biased. See the FMT with other parameters, and then try each one:

Fmt=1 ==> failed fmt=delimited ("+"  "+") ==> failed

And then see on the Internet that you can change the registry, because the default value of the comma is set in the registration table, this is the path:

Hkey_local_machine\software\microsoft\jet\4.0\engines\text\format

But I couldn't find it. Because the system is win8 possible location is not the same pit dad ... Google also can't get on ... So the way to change the registry has not been tried. And it is not recommended to change the registry.

Serach on the internet for half a day, and finally found a more magical solution for me, the use of schema.ini files.

Create a file in the same directory as the CSV file, and then write the content:

[Order.csv] format=tabdelimitedcolnameheader=truemaxscanrows=0col1=orderid text Width tencol2=ordername text Width   

Run the program and get the expected results:

OLE DB reads a CSV file: using the specified separator symbol

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.