fgetcsv: counting row length efficiency
Posted: Wed Mar 17, 2004 9:05 am
hello:
I am opening a .csv file which will then be sent over to a mysql table;
I am searching for the longest row in the .csv, ie mnoc(max_number_of_columns);
this seems like a terribly inefficient way to count the 'length' of each row in a .csv file;
any thoughts?
thanks
Shannon Burnett
Asheville NC USA
I am opening a .csv file which will then be sent over to a mysql table;
I am searching for the longest row in the .csv, ie mnoc(max_number_of_columns);
Code: Select all
function mnoc($csv_file)
{ $mnoc = 0;
$file_pointer = fopen( $csv_file , "r");
while ($row_pointer_array = fgetcsv($file_pointer, 2000, ","))
{ if ( count($row_pointer_array) > $mnoc)
{ $mnoc = count($row_pointer_array);
};
};
};any thoughts?
thanks
Shannon Burnett
Asheville NC USA