 |
|
 |
|
Next: sql learning tool
|
| Author |
Message |
External

Since: Sep 17, 2007 Posts: 2
|
(Msg. 1) Posted: Mon Sep 17, 2007 9:05 am
Post subject: Microsoft Text Driver dropping some data during reading Archived from groups: microsoft>public>vb>general>discussion, others (more info?)
|
|
|
I am using the Microsoft Text Driver (DSN-less mode) to read CSV files
in my application. these files are comma delimited, but not quoted by
double-quotes. they come from many customers, so I cannot easily
control their format.
I have found that when using the DSN-less connection of the Microsoft
Text Driver, in some cases it will not read some data.
more specifically - if you have a column that for some rows has a
numeric value, it seems the driver treats this column as numeric, and
if you have a non-numeric value in any other row for same column it
will not read the value (it will be NULL or empty)
This is not happening if the fields are quoted by double-quotes, but
again, this is coming from the clients.
any ideas ?
this is how I open and read the CSV file:
==============================
set conn = Server.CreateObject("ADODB.Connection")
set RS = Server.CreateObject("ADODB.RecordSet")
conn.Open "Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
"Dbq=" & aPath & ";" & _
"Extensions=asc,csv,tab,txt" ,"", ""
sSQL = "SELECT * FROM " & aFileName
set rs = conn.Execute(sSQL)
do while not RS.EOF
.....
and this sample CSV ilustrates the issue. look at "field1"
========================================
Field1, Field2
1234,text
5678,text 2
nonmeric,text 3
the value for RS("Field1") for the last row will by NULL! >> Stay informed about: Microsoft Text Driver dropping some data during reading |
|
| Back to top |
|
 |  |
External

Since: Sep 17, 2007 Posts: 3
|
(Msg. 2) Posted: Mon Sep 17, 2007 10:11 am
Post subject: Re: Microsoft Text Driver dropping some data during reading [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
You need to look into using a Schema file. Also, there is a registry key
that you can tweak to get it to behave better (But I don't know what it is
off hand.)
Here is an article from MS, you can also find tons of info on the subject
on google, just search for ADO Schema.ini
http://msdn2.microsoft.com/en-us/library/ms974559.aspx
Lance
"yoram ayalon" wrote in message
>I am using the Microsoft Text Driver (DSN-less mode) to read CSV files
> in my application. these files are comma delimited, but not quoted by
> double-quotes. they come from many customers, so I cannot easily
> control their format.
>
> I have found that when using the DSN-less connection of the Microsoft
> Text Driver, in some cases it will not read some data.
>
> more specifically - if you have a column that for some rows has a
> numeric value, it seems the driver treats this column as numeric, and
> if you have a non-numeric value in any other row for same column it
> will not read the value (it will be NULL or empty)
>
> This is not happening if the fields are quoted by double-quotes, but
> again, this is coming from the clients.
>
>
> any ideas ?
>
> this is how I open and read the CSV file:
> ==============================
>
> set conn = Server.CreateObject("ADODB.Connection")
> set RS = Server.CreateObject("ADODB.RecordSet")
> conn.Open "Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
> "Dbq=" & aPath & ";" & _
> "Extensions=asc,csv,tab,txt" ,"", ""
>
> sSQL = "SELECT * FROM " & aFileName
> set rs = conn.Execute(sSQL)
>
> do while not RS.EOF
> ....
>
>
> and this sample CSV ilustrates the issue. look at "field1"
> ========================================
> Field1, Field2
> 1234,text
> 5678,text 2
> nonmeric,text 3
>
>
> the value for RS("Field1") for the last row will by NULL!
> >> Stay informed about: Microsoft Text Driver dropping some data during reading |
|
| Back to top |
|
 |  |
External

Since: Sep 17, 2007 Posts: 2
|
(Msg. 3) Posted: Mon Sep 17, 2007 10:16 am
Post subject: Re: Microsoft Text Driver dropping some data during reading [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
thanks for the quick and acurate help!
the schema.ini method works! it was a bit tricky for me since I have
to create it on the fly, as the path and file names are dynamic, but
it works like a dream: my SCHEMA.INI file looks like this:
[Filename]
Format=CSVDelimited
Col1=Field1 Text
Col2=Field2 Text
....
and no code changes were neccessary, except generating the INI file.
thanks again
On Sep 17, 12:11 pm, "Lance Wynn" wrote:
> You need to look into using a Schema file. Also, there is a registry key
> that you can tweak to get it to behave better (But I don't know what it is
> off hand.)
> Here is an article from MS, you can also find tons of info on the subject
> on google, just search for ADO Schema.ini
>
> http://msdn2.microsoft.com/en-us/library/ms974559.aspx
>
> Lance
>
> "yoram ayalon" wrote in message
>
>
>
>
>
> >I am using the Microsoft Text Driver (DSN-less mode) to read CSV files
> > in my application. these files are comma delimited, but not quoted by
> > double-quotes. they come from many customers, so I cannot easily
> > control their format.
>
> > I have found that when using the DSN-less connection of the Microsoft
> > Text Driver, in some cases it will not read some data.
>
> > more specifically - if you have a column that for some rows has a
> > numeric value, it seems the driver treats this column as numeric, and
> > if you have a non-numeric value in any other row for same column it
> > will not read the value (it will be NULL or empty)
>
> > This is not happening if the fields are quoted by double-quotes, but
> > again, this is coming from the clients.
>
> > any ideas ?
>
> > this is how I open and read the CSV file:
> > ==============================
>
> > set conn = Server.CreateObject("ADODB.Connection")
> > set RS = Server.CreateObject("ADODB.RecordSet")
> > conn.Open "Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
> > "Dbq=" & aPath & ";" & _
> > "Extensions=asc,csv,tab,txt" ,"", ""
>
> > sSQL = "SELECT * FROM " & aFileName
> > set rs = conn.Execute(sSQL)
>
> > do while not RS.EOF
> > ....
>
> > and this sample CSV ilustrates the issue. look at "field1"
> > ========================================
> > Field1, Field2
> > 1234,text
> > 5678,text 2
> > nonmeric,text 3
>
> > the value for RS("Field1") for the last row will by NULL!- Hide quoted text -
>
> - Show quoted text - >> Stay informed about: Microsoft Text Driver dropping some data during reading |
|
| Back to top |
|
 |  |
External

Since: Sep 18, 2007 Posts: 2
|
(Msg. 4) Posted: Tue Sep 18, 2007 11:15 am
Post subject: Re: Microsoft Text Driver dropping some data during reading [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
I'm having a problem similar to the one Yoram was having. I'm importing a
set of names and addresses from a .csv file. Every thing works fine except
for the Zip Code field. If the field contains a standard 5 digit zip
everything is fine. But if the field contains an extended zip code like
21134-4121 the field is imported as a null for that particular zip only. In
other words, if I have 3 records where the zip codes are 06531, 21134-4121,
85441, the 06531 and 85441 zips are fine but 21134-4121 is null. I've tried
using a schema.ini file but it either doesn't fix this problem or I'm using
it incorrectly. Do I have to point to the schema.ini file in some way (it's
in the same folder as the text file I'm importing)? Do I have to specify
each column and it's type? Any help would be appreciated.
Thanks
Jim
"yoram ayalon" wrote in message
>I am using the Microsoft Text Driver (DSN-less mode) to read CSV files
> in my application. these files are comma delimited, but not quoted by
> double-quotes. they come from many customers, so I cannot easily
> control their format.
>
> I have found that when using the DSN-less connection of the Microsoft
> Text Driver, in some cases it will not read some data.
>
> more specifically - if you have a column that for some rows has a
> numeric value, it seems the driver treats this column as numeric, and
> if you have a non-numeric value in any other row for same column it
> will not read the value (it will be NULL or empty)
>
> This is not happening if the fields are quoted by double-quotes, but
> again, this is coming from the clients.
>
>
> any ideas ?
>
> this is how I open and read the CSV file:
> ==============================
>
> set conn = Server.CreateObject("ADODB.Connection")
> set RS = Server.CreateObject("ADODB.RecordSet")
> conn.Open "Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
> "Dbq=" & aPath & ";" & _
> "Extensions=asc,csv,tab,txt" ,"", ""
>
> sSQL = "SELECT * FROM " & aFileName
> set rs = conn.Execute(sSQL)
>
> do while not RS.EOF
> ....
>
>
> and this sample CSV ilustrates the issue. look at "field1"
> ========================================
> Field1, Field2
> 1234,text
> 5678,text 2
> nonmeric,text 3
>
>
> the value for RS("Field1") for the last row will by NULL!
> >> Stay informed about: Microsoft Text Driver dropping some data during reading |
|
| Back to top |
|
 |  |
External

Since: Sep 17, 2007 Posts: 3
|
(Msg. 5) Posted: Tue Sep 18, 2007 12:01 pm
Post subject: Re: Microsoft Text Driver dropping some data during reading [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
You do have to specify each field, and it's type. The Zip field should be
text.
"James D. Houston" wrote in message
> I'm having a problem similar to the one Yoram was having. I'm importing a
> set of names and addresses from a .csv file. Every thing works fine
> except for the Zip Code field. If the field contains a standard 5 digit
> zip everything is fine. But if the field contains an extended zip code
> like 21134-4121 the field is imported as a null for that particular zip
> only. In other words, if I have 3 records where the zip codes are 06531,
> 21134-4121, 85441, the 06531 and 85441 zips are fine but 21134-4121 is
> null. I've tried using a schema.ini file but it either doesn't fix this
> problem or I'm using it incorrectly. Do I have to point to the schema.ini
> file in some way (it's in the same folder as the text file I'm importing)?
> Do I have to specify each column and it's type? Any help would be
> appreciated.
>
> Thanks
>
> Jim
> "yoram ayalon" wrote in message
>
>>I am using the Microsoft Text Driver (DSN-less mode) to read CSV files
>> in my application. these files are comma delimited, but not quoted by
>> double-quotes. they come from many customers, so I cannot easily
>> control their format.
>>
>> I have found that when using the DSN-less connection of the Microsoft
>> Text Driver, in some cases it will not read some data.
>>
>> more specifically - if you have a column that for some rows has a
>> numeric value, it seems the driver treats this column as numeric, and
>> if you have a non-numeric value in any other row for same column it
>> will not read the value (it will be NULL or empty)
>>
>> This is not happening if the fields are quoted by double-quotes, but
>> again, this is coming from the clients.
>>
>>
>> any ideas ?
>>
>> this is how I open and read the CSV file:
>> ==============================
>>
>> set conn = Server.CreateObject("ADODB.Connection")
>> set RS = Server.CreateObject("ADODB.RecordSet")
>> conn.Open "Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
>> "Dbq=" & aPath & ";" & _
>> "Extensions=asc,csv,tab,txt" ,"", ""
>>
>> sSQL = "SELECT * FROM " & aFileName
>> set rs = conn.Execute(sSQL)
>>
>> do while not RS.EOF
>> ....
>>
>>
>> and this sample CSV ilustrates the issue. look at "field1"
>> ========================================
>> Field1, Field2
>> 1234,text
>> 5678,text 2
>> nonmeric,text 3
>>
>>
>> the value for RS("Field1") for the last row will by NULL!
>>
>
> >> Stay informed about: Microsoft Text Driver dropping some data during reading |
|
| Back to top |
|
 |  |
External

Since: Sep 18, 2007 Posts: 2
|
(Msg. 6) Posted: Tue Sep 18, 2007 2:58 pm
Post subject: Re: Microsoft Text Driver dropping some data during reading [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Lance,
Should the line for zip read Col12=zip Text? Is it case sensitive? And can
I skip over blank columns or columns I don't want to import?
Thanks for your help
Jim
"Lance Wynn" wrote in message
> You do have to specify each field, and it's type. The Zip field should be
> text.
>
> "James D. Houston" wrote in message
>
>> I'm having a problem similar to the one Yoram was having. I'm importing
>> a set of names and addresses from a .csv file. Every thing works fine
>> except for the Zip Code field. If the field contains a standard 5 digit
>> zip everything is fine. But if the field contains an extended zip code
>> like 21134-4121 the field is imported as a null for that particular zip
>> only. In other words, if I have 3 records where the zip codes are 06531,
>> 21134-4121, 85441, the 06531 and 85441 zips are fine but 21134-4121 is
>> null. I've tried using a schema.ini file but it either doesn't fix this
>> problem or I'm using it incorrectly. Do I have to point to the
>> schema.ini file in some way (it's in the same folder as the text file I'm
>> importing)? Do I have to specify each column and it's type? Any help
>> would be appreciated.
>>
>> Thanks
>>
>> Jim
>> "yoram ayalon" wrote in message
>>
>>>I am using the Microsoft Text Driver (DSN-less mode) to read CSV files
>>> in my application. these files are comma delimited, but not quoted by
>>> double-quotes. they come from many customers, so I cannot easily
>>> control their format.
>>>
>>> I have found that when using the DSN-less connection of the Microsoft
>>> Text Driver, in some cases it will not read some data.
>>>
>>> more specifically - if you have a column that for some rows has a
>>> numeric value, it seems the driver treats this column as numeric, and
>>> if you have a non-numeric value in any other row for same column it
>>> will not read the value (it will be NULL or empty)
>>>
>>> This is not happening if the fields are quoted by double-quotes, but
>>> again, this is coming from the clients.
>>>
>>>
>>> any ideas ?
>>>
>>> this is how I open and read the CSV file:
>>> ==============================
>>>
>>> set conn = Server.CreateObject("ADODB.Connection")
>>> set RS = Server.CreateObject("ADODB.RecordSet")
>>> conn.Open "Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
>>> "Dbq=" & aPath & ";" & _
>>> "Extensions=asc,csv,tab,txt" ,"", ""
>>>
>>> sSQL = "SELECT * FROM " & aFileName
>>> set rs = conn.Execute(sSQL)
>>>
>>> do while not RS.EOF
>>> ....
>>>
>>>
>>> and this sample CSV ilustrates the issue. look at "field1"
>>> ========================================
>>> Field1, Field2
>>> 1234,text
>>> 5678,text 2
>>> nonmeric,text 3
>>>
>>>
>>> the value for RS("Field1") for the last row will by NULL!
>>>
>>
>>
>
> >> Stay informed about: Microsoft Text Driver dropping some data during reading |
|
| Back to top |
|
 |  |
External

Since: Sep 17, 2007 Posts: 3
|
(Msg. 7) Posted: Tue Sep 18, 2007 3:27 pm
Post subject: Re: Microsoft Text Driver dropping some data during reading [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Yes, I believe that is what the syntax is. It is not case sensitive. I am
not sure about the omitted columns requirement. you can try it and see, but
to be safe, I'd go ahead and include them all just in case you need them in
the future.
Lance
"James D. Houston" wrote in message
> Lance,
>
> Should the line for zip read Col12=zip Text? Is it case sensitive? And
> can I skip over blank columns or columns I don't want to import?
>
> Thanks for your help
>
> Jim
>
> "Lance Wynn" wrote in message
>
>> You do have to specify each field, and it's type. The Zip field should
>> be text.
>>
>> "James D. Houston" wrote in message
>>
>>> I'm having a problem similar to the one Yoram was having. I'm importing
>>> a set of names and addresses from a .csv file. Every thing works fine
>>> except for the Zip Code field. If the field contains a standard 5 digit
>>> zip everything is fine. But if the field contains an extended zip code
>>> like 21134-4121 the field is imported as a null for that particular zip
>>> only. In other words, if I have 3 records where the zip codes are
>>> 06531, 21134-4121, 85441, the 06531 and 85441 zips are fine but
>>> 21134-4121 is null. I've tried using a schema.ini file but it either
>>> doesn't fix this problem or I'm using it incorrectly. Do I have to
>>> point to the schema.ini file in some way (it's in the same folder as the
>>> text file I'm importing)? Do I have to specify each column and it's
>>> type? Any help would be appreciated.
>>>
>>> Thanks
>>>
>>> Jim
>>> "yoram ayalon" wrote in message
>>>
>>>>I am using the Microsoft Text Driver (DSN-less mode) to read CSV files
>>>> in my application. these files are comma delimited, but not quoted by
>>>> double-quotes. they come from many customers, so I cannot easily
>>>> control their format.
>>>>
>>>> I have found that when using the DSN-less connection of the Microsoft
>>>> Text Driver, in some cases it will not read some data.
>>>>
>>>> more specifically - if you have a column that for some rows has a
>>>> numeric value, it seems the driver treats this column as numeric, and
>>>> if you have a non-numeric value in any other row for same column it
>>>> will not read the value (it will be NULL or empty)
>>>>
>>>> This is not happening if the fields are quoted by double-quotes, but
>>>> again, this is coming from the clients.
>>>>
>>>>
>>>> any ideas ?
>>>>
>>>> this is how I open and read the CSV file:
>>>> ==============================
>>>>
>>>> set conn = Server.CreateObject("ADODB.Connection")
>>>> set RS = Server.CreateObject("ADODB.RecordSet")
>>>> conn.Open "Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
>>>> "Dbq=" & aPath & ";" & _
>>>> "Extensions=asc,csv,tab,txt" ,"", ""
>>>>
>>>> sSQL = "SELECT * FROM " & aFileName
>>>> set rs = conn.Execute(sSQL)
>>>>
>>>> do while not RS.EOF
>>>> ....
>>>>
>>>>
>>>> and this sample CSV ilustrates the issue. look at "field1"
>>>> ========================================
>>>> Field1, Field2
>>>> 1234,text
>>>> 5678,text 2
>>>> nonmeric,text 3
>>>>
>>>>
>>>> the value for RS("Field1") for the last row will by NULL!
>>>>
>>>
>>>
>>
>>
>
> >> Stay informed about: Microsoft Text Driver dropping some data during reading |
|
| Back to top |
|
 |  |
External

Since: Sep 02, 2003 Posts: 236
|
(Msg. 8) Posted: Wed Sep 19, 2007 8:07 am
Post subject: Re: Microsoft Text Driver dropping some data during reading [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
|
|
| Back to top |
|
 |  |
| Related Topics: | [Microsoft][ODBC dBase driver]External Table is not in the.. - I have 3 computers, 2 of which have Visual Studio 6 SP5 installed as well as may other apps. The 3rd computer has very few apps other than Apache. I have a small VB6 app that puts together a special report from a number of dBase files. I used the..
Reading Excel from Visual Basic 6.0 - I need to know, how can I read an excel file using visual basic and then save the data in another format. I do not want to use databases at all. Is it posible? Thanks a lot, Lina
ISAM driver query - Hi, I am developer in Visual Basic 6.0 and SP4 application development and database use MS Access XP and SQL 7.0. This field last 6years and I am use Clipper 5.3, 5.2(Compiler) and Foxpro 2.6, Dbase IV(Database). At now I am totaly convert in VB so I am...
Change connect string for Excel Queries using an ODBC Driver - Reference: ODBC Connection for MAS90 MAS200 In Excel we have an ODBC Connection String with a physical (hard coded) path to the data. We have changed the servers. We do not want to recreate all of the queries. How can we edit the ODBC path inside of..
MsAccess data from Accpac Plus Data - We would like to create an MsAccess.Mdb in office 2000 to obtain individual table details from Accpac Plus in Dos (an accounting program)? Can we receive any ideas or a sample database of how to do this? Thank you Mehran |
|
You can post new topics in this forum You can reply to topics in this forum You can edit your posts in this forum You can delete your posts in this forum You can vote in polls in this forum
|
|
|
|
 |
|
|