[英]How best to convert from azure blob csv format to pandas dataframe while running notebook in azure ml
[英]How to read .xpt format file from the Azure ADLS blob container and convert to csv format
将 .xpt 格式文件从 URL 下载到 Databricks - Python 笔记本中的 blob 容器。
在下面的代码中 - 'example.xpt' 是本地文件。 如何从blob容器中读取.xpt格式文件?
import xport.v56
with open('example.xpt', 'rb') as f:
library = xport.v56.load(f)
感谢任何输入。 谢谢!
考虑到您已经在集群中安装了库xport
并安装了 ADLS blob 容器,请按照以下步骤操作:
.xpt
文件。import xport.v56
with open('/dbfs/mnt/repro/ALQY_F.XPT', 'rb') as f:
# '/dbfs/mnt/repro/' refers to the mount point i.e., to ADLS blob container.
library = xport.v56.load(f)
库object 的类型为class 'xport.v56.Library'
。 library
有一个属性values
,它返回一个可迭代的 object。
使用以下代码将所需数据写入指定目的地的csv
格式
for data in library.values():
print(type(data)) # <class 'xport.v56.Member'>
print(dir(data)) # use to check all the possible attributes that can be used on this object
data.to_csv("/dbfs/mnt/repro/op.csv") #writes as csv to your blob container.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.