MQTT message from csv file

I have a csv file and I need to send this file as a MQTT message, but I need it to sending just by one line with a few seconds of break and then next line and again a few sec break. It's something like sensor simulation but with data in csv file. I've tried to solve it in several different ways but nothing worked. I'm coding in Python. Thank you guys for any help.

def MQTT_publish():
  client = mqtt.Client()
  reader = csv.reader(file)
  print("Connecting to broker", broker)
  client.connect(broker)
  client.loop_start()
  print("Publishing...")
  for row in reader:
    for e in row:
        client.publish(f"{topic}", str(e))
  time.sleep(10)

  client.loop_stop()


from Recent Questions - Stack Overflow https://ift.tt/2V3n3x2
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

I get wrong characters when retreiving the message body of an email using TIdIMAP4.UIDRetrieveTextPeek2()

How to drop the all the 1's in a correlation matrix

Today Walkin 14th-Sept