ignoring commas in individual fields when parsing CSV file
Posted: Thu Apr 20, 2006 12:08 am
Hello,
I'm trying to develop a bullet proof CSV function that can ignore commas that are found in individual field data when parsing through a regular CSV file.
Here's some of the code I'm trying right now:
php:
Any help you can give would be awesome.
Thanks,
Clem
I'm trying to develop a bullet proof CSV function that can ignore commas that are found in individual field data when parsing through a regular CSV file.
Here's some of the code I'm trying right now:
php:
Code: Select all
$file = fopen( $file_name, "r" );
$cnt = 0;
while( !feof( $file ))
{
$line = fgetcsv( $file, 4096 );
$count = count( $line );
if( is_array( $line ) && $count > 0 )
{
for( $i = 0; $i < $count ; $i++ )
{
echo "<br>$line[$i] ";
}
}
}
fclose( $file );Thanks,
Clem