note 40553 added to function.fgetcsv

From: Date: Sun, 07 Mar 2004 20:52:44 +0000
Subject: note 40553 added to function.fgetcsv
Groups: php.notes 
Request: Send a blank email to php-notes+get-66404@lists.php.net to get a copy of this message
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!). ---- Manual Page -- http://www.php.net/manual/en/function.fgetcsv.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+40553 Delete -- http://master.php.net/manage/user-notes.php?action=delete+40553&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+40553&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#66404) next »