Kafka producer write in different topics

Hi I’m new on Kafka. I have a meteo station and it sends data to Kafka (Confluent Platform). In Kafka I have 4 topics: rain, wind, temperature, humidity.
I query the meteo stastion throught an API and it responses with a xml:

I’m using a python client to implement a producer to acquire data from station API and I want to write data in diffetent topic: I process row by row meteo data
and according the measure (temperature, humidity, etc) I want to write it in the corresponding Kafka topic.
In past I tried to write only in one topic in this manner:

./script_name.py -f $HOME/.confluent/librdkafka.config -t topic_name

If i wan’t to pass the topic name in the command but I define the topic in dynamic manner in the script…how can I made it?
Thanks for your support.

Hi Giuseppe,

If you are always going to have four topics, would it work to modify your script to take three additional topic arguments? For example, rain_topic_name, wind_topic_name, etc. Or you could pass all four in a delimited string and parse them inside your script.

Or am I over-simplifying the problem?


Hi @daveklein your solution may be a good proposal. there is another more simple solution?