【问题标题】:Trying to read events from event hub in azure databricks in python尝试从 python 中的 azure databricks 中的事件中心读取事件
【发布时间】:2019-09-23 18:34:15
【问题描述】:

我正在尝试从事件中心读取数据。我通过事件中心发件人将 twitter 数据作为 json 发送。 当我尝试读取数据并将其附加到列表中时,出现以下错误。我可能错在哪里? 下面的代码:

        for tweet in ts.search_tweets_iterable(tso):
            print(tweet)
            sender.send(EventData(tweet))


try:
    receiver = client.add_receiver(CONSUMER_GROUP, PARTITION, prefetch=5000, offset=OFFSET)
    client.run()
    start_time = time.time()
    for event_data in receiver.receive(timeout=100):
        last_offset = event_data.offset
        last_sn = event_data.sequence_number
        messages.append(next(event_data.body))
        total += 1

我收到以下错误:

TypeError: 'dict' 对象不是迭代器

【问题讨论】:

  • 错误信息指出:'dict' 对象不是迭代器。你应该看看错误在哪一行抛出,哪个变量是导致错误的dict。

标签: python azure-eventhub azure-databricks


【解决方案1】:

根据错误信息:TypeError: 'dict' object is not an iterator.

这意味着您使用“dict”类型而不是迭代器。您应该检查您的代码是哪个“dict”类型导致此错误。然后你可以使用iter()函数将dict转换为迭代器。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-10-23
    • 1970-01-01
    • 2018-07-19
    • 2020-12-17
    • 1970-01-01
    • 1970-01-01
    • 2019-07-23
    相关资源
    最近更新 更多