我有一个很大的 csv,我想写一个 kafka 主题。
def producer():
producer = KafkaProducer(bootstrap_servers='mykafka-broker')
with open('/home/antonis/repos/testfile.csv') as file:
reader = csv.DictReader(file, delimiter=";")
for row in reader:
producer.send(topic='stable_topic', value=row)
producer.flush()
if __name__ == '__main__':
producer()
此代码产生错误:
AssertionError: value must be bytes
该文件如下所示:
"timestamp","name","age"
2020-03-01 00:00:01,John,36
2020-03-01 00:00:01,Peter,22
谁能帮我这个?