简体   繁体   English

如何从 azure blob 存储中读取地震数据

[英]how to read seismic data from azure blob storage


from azure.storage.blob import BlobServiceClient

import os

STORAGEACCOUNTURL = ""

STORAGEACCOUNTKEY = ""

CONTAINERNAME = ""

BLOBNAME = ""

blob_service_client_instance = BlobServiceClient(

account_url=STORAGEACCOUNTURL, credential=STORAGEACCOUNTKEY)

blob_client_instance = blob_service_client_instance.get_blob_client(

CONTAINERNAME, BLOBNAME)

blob_data = blob_client_instance.download_blob()

data = blob_data.readall()

print(data)

ERROR:错误:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc3 in position 0: invalid continuation byte UnicodeDecodeError:“utf-8”编解码器无法解码 position 中的字节 0xc3 0:无效的继续字节

Getting error while execute it.执行时出错。 Kindly guide how to read seismic data(more than 1gb) file using azure blob storage using python请指导如何使用 azure 使用 python 的 blob 存储读取地震数据(超过 1gb)文件

After reproducing from my end, I observed that you are receiving this error due to the presence of non-utf8 characters present in your file.从我的结尾复制后,我观察到您收到此错误是因为您的文件中存在非 utf8 字符。 Make sure you decode the data before printing.确保在打印前解码数据。

decoded_data = data.decode('utf-8')

Below is the complete code that's working for me.以下是对我有用的完整代码。

from azure.storage.blob import BlobServiceClient
import os

STORAGEACCOUNTURL = "<Your_Storage_URL>"
STORAGEACCOUNTKEY = "<Your_Storage_Account>"
CONTAINERNAME = "<Your_Container>"
BLOBNAME = "<Your_Blob_Name>"

blob_service_client_instance = BlobServiceClient(
account_url=STORAGEACCOUNTURL, credential=STORAGEACCOUNTKEY)
blob_client_instance = blob_service_client_instance.get_blob_client(CONTAINERNAME, BLOBNAME)
blob_data = blob_client_instance.download_blob()
data = blob_data.readall()

decoded_data = data.decode('utf-8')

print(decoded_data)

RESULTS:结果:

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM