Skip to content

Instantly share code, notes, and snippets.

@merlin-quix
Last active January 22, 2023 13:21
Show Gist options
  • Save merlin-quix/5d8e30ac034402bbee41b4b0a5531584 to your computer and use it in GitHub Desktop.
Save merlin-quix/5d8e30ac034402bbee41b4b0a5531584 to your computer and use it in GitHub Desktop.
# importing packages
import pandas as pd
import time, json
import datetime as dt
import requests
from kafka import KafkaProducer
df = pd.read_csv("spam.csv")
# initializing Kafka Producer Client
producer = KafkaProducer(bootstrap_servers=['localhost:9092'],
value_serializer=lambda x:
json.dumps(x,default=str).encode('utf-8'))
print(f'Initialized Kafka producer at {dt.datetime.utcnow()}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment