亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在Windows 10上使用avro-python3解析文件?

如何在Windows 10上使用avro-python3解析文件?

墨色風雨 2023-09-19 13:59:26
我已將 AVRO 文件(帶有 JSON 負載)從 Microsoft Azure 下載到我的 Windows 10 計算機:然后通過 pip 安裝 python 3.8.5 和 avro 1.10.0 我嘗試運行以下腳本:import os, avrofrom avro.datafile import DataFileReader, DataFileWriterfrom avro.io import DatumReader, DatumWriterreader = DataFileReader(open("48.avro", "rb"), DatumReader())for d in reader:    print(d)reader.close()不幸的是,腳本沒有打印任何內容。然后我四處搜索并嘗試添加如下所示的架構:schema_str = """{  "type" : "record",  "name" : "EventData",  "namespace" : "Microsoft.ServiceBus.Messaging",  "fields" : [ {    "name" : "SequenceNumber",    "type" : "long"  }, {    "name" : "Offset",    "type" : "string"  }, {    "name" : "EnqueuedTimeUtc",    "type" : "string"  }, {    "name" : "SystemProperties",    "type" : {      "type" : "map",      "values" : [ "long", "double", "string", "bytes" ]    }  }, {    "name" : "Properties",    "type" : {      "type" : "map",      "values" : [ "long", "double", "string", "bytes", "null" ]    }  }, {    "name" : "Body",    "type" : [ "null", "bytes" ]  } ]}"""schema = avro.schema.parse(schema_str)reader = DataFileReader(open("48.avro", "rb"), DatumReader(schema, schema))for d in reader:    print(d)reader.close()但這并沒有幫助,仍然沒有打印任何內容。雖然我期待會打印字典對象列表......
查看完整描述

1 回答

?
喵喔喔

TA貢獻1735條經驗 獲得超5個贊

正如 OneCricketeer 建議使用 PySpark 讀取 EventHub 生成的 avro 文件。此處,PySpark:反序列化 eventhub 捕獲 avro 文件中包含的 Avro 序列化消息就是這樣的示例。



查看完整回答
反對 回復 2023-09-19
  • 1 回答
  • 0 關注
  • 145 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號