Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #!/usr/bin/env php
  2. <?php
  3. /**
  4. * Usage:
  5. * php aggr.php < 資材ログ.csv > out.csv
  6. * nkf -Ws -Lw out.csv > 資材ログ.csv
  7. */
  8.  
  9. $src = 'php://filter/read=convert.iconv.cp932%2Futf-8/resource=php://stdin';
  10. $file = new SplFileObject($src);
  11. $file->setFlags(SplFileObject::DROP_NEW_LINE);
  12. $lines = [];
  13. foreach ($file as $line) {
  14. $date = explode(' ', $line, 2)[0];
  15. $lines[$date] = $line . "\n";
  16. }
  17. file_put_contents('php://stdout', $lines);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement