update page now

Voting

: five minus four?
(Example: nine)

The Note You're Voting On

faure dot daniel dot 57 at gmail dot com
4 years ago
Given an absolute path to a CSV or any text file and a list of possible delimiters and assuming lines are up to 4096 characters long, I use
<?php 
function guess_delimiter($file, $delimiters=[',',';']) 
{
 $h = fopen($file,'r');
 $count = [];
 foreach ($delimiters as $del) {
 $count[$del] = 0;
 while (($bufer = fgets($h, 4096)) !== false) {
 $count[$del]+=substr_count($bufer, $del);
 }
 rewind($h);
 }
 fclose($h);
 return array_search(max($count), $count);
}

<< Back to user notes page

AltStyle によって変換されたページ (->オリジナル) /