I actually do use fopen to connect to the file and create a table based on the column 
names I gather from the first line.  However, actaully parsing through the file and 
trying to dynamically create insert statements for each row seems like it would be a 
regular expression nightmare.  I really can't guarantee the format of the csv in any 
way that is easy to work with... for instance, the first data line might look like 

"2","Ethan Nelson","My favorite quote is ""To hell with them"".","just a test"\r\n

As you can see, If I'm going to preserve the double quotes in the third column, I 
would have to come up with a script that would deal with escaped characters.

I was hoping that I could just establish an ODBC connection to the text file, which it 
appears that I can, and then select stuff from it.  Microsoft's documentation that I 
could find states that their text driver doesn't support create/drop table, insert, or 
update commands (obviously), but it doesn't mention SELECT as being off limits...


-----Original Message-----
From: Jay Blanchard [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 10, 2002 11:48 AM
To: Ethan Nelson; [EMAIL PROTECTED]
Subject: RE: [PHP] ODBC text file connection problem

I've got one for ya.  I've been trying to conenct to a csv text file =
(comma delimited, \r\n row separators, and " text qualifiers) using the =
odbc_connect command and then run simple select statements through it.  =
It doesn't work and I'm at a loss for why.  

Why not use fopen()? A CSV file is a plain text file and therefore cannot be treated 
as a database. The CSV file has no data engine with which to connect to.



* Texas PHP Developers Conf  Spring 2003            *
* T Bar M Resort & Conference Center                *
* New Braunfels, Texas                              *
* Contact [EMAIL PROTECTED]       *
*                                                   *
* Want to present a paper or workshop? Contact now! *

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to