2

I am trying to parse a growing csv file with the following script parse.py:

import csv
import sys

reader = csv.reader(sys.stdin)
for row in reader:
    print row

The corresponding command line is tail -F log | python parse.py.

Then I try to append some rows to log with echo "something" >> log.

But parse.py print nothing.

What's wrong with my script?

satoru
  • 31,822
  • 31
  • 91
  • 141

1 Answers1

2

The problem you're having is that what you're adding to the log file is being buffered and not passed to the other commands in the pipeline.

For more information, please have a look at how big is the pipe buffer.

Community
  • 1
  • 1
jcollado
  • 39,419
  • 8
  • 102
  • 133
  • Related question http://stackoverflow.com/questions/1544050/force-another-programs-standard-output-to-be-unbuffered-using-python – Artem Koshelev Feb 27 '12 at 09:09