Search code examples
pythoncsvreal-time-updates

Read csv in real time with python


I have a csv file that is writing some information on real-time with cicflowmeter. Is there a way to catch every new row in the time that it is writed with a python script?


Solution

  • This problem can be solved without any python code. Just run something like tail -n0 -f logfile.csv | python3 program.py and have your program read from stdin like this:

    import sys
    
    for line in sys.stdin:
        # do something