ODBC读取CSV文件时候的Schema.ini
Jun 07, 2016 pm 03:08 PMMSDN上说明很详细:http://msdn.microsoft.com/en-us/library/windows/desktop/ms709353(v=vs.85).aspx 举个例子来说,test.csv 文件 内容如下 Type,V1,V2,Qty 19809,123,124,34 2ab23,343,435,22 23456,908,987,16 我遇到的情况是,SQL SERVER数据库,用OPE
MSDN上说明很详细:http://msdn.microsoft.com/en-us/library/windows/desktop/ms709353(v=vs.85).aspx
举个例子来说,test.csv文件内容如下
Type,V1,V2,Qty
19809,123,124,34
2ab23,343,435,22
23456,908,987,16
我遇到的情况是,SQL SERVER数据库,用OPENDATASET访问(out of scope),结果是Type这一列中只能够读取到第一、三行,而第二行的数据被忽略掉。猜测是因为默认Type列的类型是数值型(可能根据第一行判断),所以忽略了Type值不能够类型转换的第二行。
原来可以在CSV文件同目录下面写一个Schema.ini文件,在使用ODBC Text Driver的时候,根据其中定义的Data Type Format, Character Set等设置读取CSV文件。
在test.csv文件目录下创建Schema.ini,内容如下
[test.csv]
Format=Delimited(,)
ColNameHeader=True
MaxScanRows=0
CharacterSet=ANSI
Type=F1 Char Width 100
Year=F2 Integer
Week=F3 Integer
Qty=F4 Integer
这样在读取的时候,第二行数据就不会被忽略了

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to recover expired WeChat files? Can expired WeChat files be recovered?

Photos cannot open this file because the format is not supported or the file is corrupted

PHP format rows to CSV and write file pointer

How to transfer files from Quark Cloud Disk to Baidu Cloud Disk?

What to do if the 0x80004005 error code appears. The editor will teach you how to solve the 0x80004005 error code.

What is hiberfil.sys file? Can hiberfil.sys be deleted?

Different uses of slashes and backslashes in file paths
