Hello all,
I would like to count the occurrence of all commas in a very large text file (its has comma delimited data). Size is 28mb. I thought of loading up the text file and doing something like this:
substr_count($text, ',');
Good idea? Will it work?
The overall task is to find out how many rows of data it has. When I count the number of commas, I will divide this by the number of columns which will give me the number of rows. If there is a better way of doing this, let me know!
Thanks all
EDIT
The below worked but is it efficient as the suggestions?
$lines = file('C:\wamp\CE.txt');
$number = 0;
foreach($lines as $line){
$number = $number + substr_count($line, ',');
}
echo $number;