Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env php
- <?php
- /**
- * Usage:
- * php aggr.php < 資材ログ.csv > out.csv
- * nkf -Ws -Lw out.csv > 資材ログ.csv
- */
- $src = 'php://filter/read=convert.iconv.cp932%2Futf-8/resource=php://stdin';
- $file = new SplFileObject($src);
- $file->setFlags(SplFileObject::DROP_NEW_LINE);
- $lines = [];
- foreach ($file as $line) {
- $date = explode(' ', $line, 2)[0];
- $lines[$date] = $line . "\n";
- }
- file_put_contents('php://stdout', $lines);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement