Calling subprocess.check_call()
allows to specify a file object for stdout, but before writing the data to a file, I would like to modify them on a line-by-line base.
I currently redirect the output to a temporary file (created by tempfile.TemporaryFile()
. After check_call
finished, I read that temporary file line-by-line, do the modifications and write the final output file.
Since the output is large, a pure in-memory-solution is not feasible and I would like to modify the data on-the-fly and write to the final output file directly.
Does anyone know how to achieve that?