http://php.net/manual/en/reserved.variables.argc.php
http://php.net/manual/en/reserved.variables.argv.php
http://pear.php.net/package/File_CSV/docs/latest/File/File_CSV.html
http://php.net/manual/en/reserved.variables.argv.php
http://pear.php.net/package/File_CSV/docs/latest/File/File_CSV.html
PHP PEAR File CSV
WARNING there are a number of bugs in PHP PEAR File CSV such as
- not handling CR and or CR/LF
- not correcty parsing a comma ',' as the first character of a quoted string ie 11,22,"33",",44"
so you may wish to just use PhpFile instead
pear file_csv install
# pear install channel://pear.php.net/File-1.4.0alpha1 channel://pear.php.net/File_CSV-1.0.0alpha1 channel://pear.php.net/File_Util-1.0.0alpha1
pear file_csv example
require_once 'File/CSV.php';
if ($argc != 2) {
echo "usage: ". __FILE__ . " filename.csv" . PHP_EOL ;
exit;
}
$filename = $argv[1];
$fcsv = new File_CSV;
$conf = $fcsv->discoverFormat($filename);
$fd = $fcsv->getPointer($filename,$conf);
$i=0;
while (($row=$fcsv->readQuoted($filename,$conf))!==false){
// if (count($row)) echo "{$row[0]} {$row[1]} {$row[2]}".PHP_EOL;
unset($row);
$i++;
}
echo $i;REFERRERS
PhpPear