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.
$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 |