fgetcsv enclosure argument is ignored
Posted: Wed May 03, 2006 1:40 pm
feyd | Please use
And here's an example of a line where one field contains many comma separated entities with a pipe character inserted to demonstrate where the field names should end:
115 S GRAHAM ST | Aug-05 | May-06 | 900 | 400 | 800| 202-1212 | 637-5711Brenda | Tom Beaman, Brenda Horrell |
Clem C
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello,
I'm trying to create a csv parser script that can handle fields w/ commas in them.
I'm trying this little bit of code w/ no results. The commas w/in the individual fields are ignored.Code: Select all
$file = fopen( 'import_files/' .$uploaded_file_name, "r" );
while( ( $data = fgetcsv( $file, 4096, ',', '''' ) ) !== FALSE )
{
$num = count($data);
echo "<p><b>$num fields in line $row: </b><br /></p>\n";
$row++;
for( $c=0; $c < $num; $c++ )
{
echo $data[$c] . "<br />\n";
}
}
fclose($file);
?>And here's an example of a line where one field contains many comma separated entities with a pipe character inserted to demonstrate where the field names should end:
115 S GRAHAM ST | Aug-05 | May-06 | 900 | 400 | 800| 202-1212 | 637-5711Brenda | Tom Beaman, Brenda Horrell |
Clem C
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]