note 40553 deleted from function.fgetcsv by irchtml
| From: | irchtml@php.net | Date: | Mon, 08 Mar 2004 10:52:15 +0000 |
| Subject: | note 40553 deleted from function.fgetcsv by irchtml | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-66429@lists.php.net to get a copy of this message | ||
Note Submitter: Gregory Wood
----
The function submitted by bu at orbitel dot bg won't work if any csv field contains one or more
line-breaks (actually, it doesn't seem to work even without those). In fact, any approach that
assumes that a line-break can only occur at the end of a record will fail. This is because it is
perfectly valid for a line break to appear within a csv field. No doubt this condition is what slows
the function down as it _does_ parse this correctly.
If you want to experiment for yourself, you can create a multi-line field in Excel by pressing
Alt-Enter in the field. When you save that spreadsheet as a csv file, the line will contain
line-breaks, but the field will be be wrapped by double quotes. For example, this is a two record
valid csv file:
1,Test,"This
is
a
multiline"
2,Another test,"This
is
also
a
multiline"
Ironically enough, OpenOffice avoids this problem altogether by translating line-breaks into spaces
(bad OpenOffice!).