Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 14th, 2010, 05:17 AM
Friend of Wrox
 
Join Date: Oct 2004
Location: , , .
Posts: 198
Thanks: 2
Thanked 0 Times in 0 Posts
Send a message via MSN to itHighway
Default Problem importing data from CSV

I have a CSV file with a column containing both Numeric and Text data. Using ASP code when I import the data from that column I only get Numeric data not Text.

Below is the example of data

Quote:
CODE:
499
549
234
A23
T33
YY2
I tried to convert CSV column to text but it did not work.

Please advice.


Thank you,
Zeeshan
Reply With Quote
  #2 (permalink)  
Old September 14th, 2010, 06:06 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Yes, by default, the JET OLEDB text driver (used for CSV files) only scans the first 8 rows or your table and decides what the type of your data based on that. If it only sees numbers in those first 8 rows, then that column *will* be treated as a number.

There's a long answer and a short answer.

The short answer: If your table has a HEADING row with the names of the columns, then lie to JET: Tell it that the table does *NOT* have a heading row. Now it will treat that first row as data. It will see the name in the first row and so every column will now be text type. You will no longer be able to use RS("columnname") in your ASP code, of course. Instead, you will have to use RS(0), RS(1), etc. Getting the columns by number instead of name. You can do this by just changing your connection string:
Code:
oConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
         "Data Source=c:\somepath\;" & _
         "Extended Properties=""text;HDR=No;FMT=Delimited"""
The longer answer: It's shorter for me, longer for you. <grin/> Look here:
http://support.microsoft.com/kb/210073/EN-US/
You will need to create a "schema.ini" file in the same directory as the "csv" file.

I *think* all you would need would be
Code:
[YourFileName.csv]
ColNameHeader=True
Format=Delimited
MaxScanRows=9999
Might be able to use 0 for MaxScanRows. Dunno.
Reply With Quote
  #3 (permalink)  
Old September 14th, 2010, 11:21 PM
Friend of Wrox
 
Join Date: Oct 2004
Location: , , .
Posts: 198
Thanks: 2
Thanked 0 Times in 0 Posts
Send a message via MSN to itHighway
Default

Thank you very much for replying to my post. I tried the first method but it still not reading the text values. It does read the first row which is the text.

Any idea?

Last edited by itHighway; September 14th, 2010 at 11:22 PM.. Reason: formating
Reply With Quote
  #4 (permalink)  
Old September 15th, 2010, 03:57 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Well, try the "schema.ini" solution, then. I'm surprised the first answer didn't work. I have used it, myself, in the past.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem importing CSV hman MySQL 0 January 6th, 2007 09:13 AM
Importing data from a CSV file? kr33 SQL Server 2000 26 January 3rd, 2007 02:38 AM
Importing data from CSV file g_vamsi_krish ASP.NET 1.0 and 1.1 Basics 2 May 23rd, 2006 01:29 AM
Importing data from .csv Spitzbucket PHP Databases 0 February 20th, 2005 01:42 PM



All times are GMT -4. The time now is 07:00 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.