note 38201 added to function.fgetcsv
| From: | peter at schoenster dot com | Date: | Thu, 11 Dec 2003 19:22:06 +0000 |
| Subject: | note 38201 added to function.fgetcsv | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-61825@lists.php.net to get a copy of this message | ||
Does anyone know how fgetcsv defines a CSV file? What format does it expect. It *seems* to be fine
with the following:
each field enclosed by double quotes
a double quote in a field is escaped by a double qoute
an end of record is CRLF
So I have data coming from MSSQL and I use RegEx to quote a double quote with a double quote, I
don't have to worry about new lines (or CRLF) in the data as I'm enclosing the field in
double quotes (btw, I found the VBscript regex would die where a field is null so I don't
bother to do the regex replace on it)
This seems similar to the parser mysqlimport uses and the DBD_CSV from Perl's CPAN.
I have found lots and lots of so called parsers that cannot handle embedded newlines or commas in
fields. But then the csv file must have the enclosing quotes on all data fields.
But back to my original question, is there any FIXED, KNOWN definition of what a CSV file is? As one
of my cohorts said, certainly fgetcsv must have a model. I'd like to know what it is rather
than guess.
----
Manual Page -- http://www.php.net/manual/en/function.fgetcsv.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+38201
Delete -- http://master.php.net/manage/user-notes.php?action=delete+38201&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+38201&report=yes
Search -- http://master.php.net/manage/user-notes.php