<?php
$lines = file('readfile.csv');
$cnt = count($lines);//レコード数
$i = 0;
$fp = fopen('php://temp', 'w');//一時ファイル
while($i<$cnt){
$data = explode(',',$lines[$i]);
//ここで色々な処理
mb_convert_variables('SJIS-win', 'UTF-8', $data);//文字コード変換
fputcsv($fp, array_values($data));//一時ファイルに1件書き出し
++$i;
}
rewind($fp);//ファイルポインタを先頭に戻す
file_put_contents("outputfile.csv", stream_get_contents($fp));//出力
fclose($fp);
?>
More than 3 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme