Am sending the CSV data to Kafka topic using Kafka-Python
. Data is sent and received by Consumer successfully. Now am trying to stream a csv file continuously, any new entry added to the file should be automatically sent to Kafka topic. Any suggestion would be helpful on continuous streaming of CSV file
Below is my existing code,
from kafka import KafkaProducer
import logging
from json import dumps, loads
import csv
logging.basicConfig(level=logging.INFO)
producer = KafkaProducer(bootstrap_servers='127.0.0.1:9092', value_serializer=lambda
K:dumps(K).encode('utf-8'))
with open('C:/Hadoop/Data/Job.csv', 'r') as file:
reader = csv.reader(file, delimiter = '\t')
for messages in reader:
producer.send('Jim_Topic', messages)
producer.flush()