2012年ごろに書いたもののうろ覚え版。
ファイルサイズがデカすぎてmod_phpで扱うには問題があったことと、「全てのテキストを一括でエンコーディング変換しないと、変換ミスが発生する」ケースがあったため、この様な強硬策を取った。
// SJISじゃなくてSJIS-win、EUC-JPじゃなくてeucJP-winを使うべき
$from_encoding = 'SJIS-win';
$to_encoding = 'UTF-8';
$file_path = '/path_to_csv/file.csv';
// PHPコマンドで一括変換するという暴挙
$command = sprintf("echo mb_convert_encoding(file_get_contents('%s'), '%s', '%s');", $file_path, $to_encoding, $from_encoding);
// 変換済みの"出力"をプロセスハンドルとして握る
$handle = popen(sprintf('%s -r %s', escapeshellarg(sprintf('%s/php', PHP_BINDIR)), escapeshellarg($command)), 'rb');
// 後は普通のCSV処理
$in_body = false;    // フラグとしか使わないならフラグでよくね
while (($row = fgetcsv($handle, 4000)) !== FALSE) {
	if ($in_body === false) {
		$in_body = true;
		continue;
	}
	if ($row === [null]) {
		continue;
	}
	if (count($row) !== 3) {
		throw new \RuntimeException('Unexpected number of column');
	}
	var_dump($row);
}
fclose($handle);
