In the terminal, if I execute
docker run -it --rm --name consumer --link zookeeper:zookeeper --link kafka:kafka \
debezium/kafka:1.1 watch-topic -a bankserver1.bank.holding > C:/Users/User/python_test \
/holding_pivot.txt
The log result would be written to file holding_pivot.txt
like this
WARNING: Using default BROKER_ID=1, which is valid only for non-clustered installations.
Using ZOOKEEPER_CONNECT=172.17.0.3:2181
Using KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://172.17.0.6:9092
Using KAFKA_BROKER=172.17.0.4:9092
Contents of topic bankserver1.bank.holding:
{"schema":{"type":"struct","fields":[{"type":"struct","fiel...
{"schema":{"type":"struct","fields":[{"type":"struct","file...
I want to have a python file that handle it before writing to file log (I dont want a python file that read from the log (because I have to distinguish which line is already read and handled and which line is not))
The process of the code like this
RESULT -> Python File (handle) -> writing to log file.
MAIN QUESTION: Which library of Python support it ? Can you give me a sample code ?
I saw a document like this:
docker run -it --rm --name consumer --link zookeeper:zookeeper --link kafka:kafka \
debezium/kafka:1.1 watch-topic -a bankserver1.bank.holding \
| grep --line-buffered '^{' | pipe > ./stream.py > ./holding_pivot.txt
===================== UPDATE ======================= According to @piertoni, I add this
docker run -it --rm --name consumer --link zookeeper:zookeeper --link /
kafka:kafka debezium/kafka:1.1 watch-topic -a bankserver1.bank.holding /
| python C:/Users/User/python_test/test_pipe.py > C:/Users/User/python_test /
/holding_pivot.txt
Here is my trying test_pipe.py
#!/usr/bin/env python3 -u
# Note: the -u denotes unbuffered (i.e output straing to stdout without buffering data and then writing to stdout)
#!/usr/bin/env python3
import fileinput
import json
import os
import sys
from datetime import datetime
for line in sys.stdin:
with open('log.txt', 'a') as wr:
wr.write("Pipe success")
with open('log.txt', 'a') as wr:
wr.write("Pipe success")
with fileinput.input() as f:
for line in f:
with open('log.txt', 'a') as wr:
wr.write(f"Argument List: {str(line)}")
However, nothing write to the log.txt file (I only need the python file can read the result of the initial pipe).