python - 使用databricks中的pyspark将多个json文件从blob存储读取到数据帧
问题描述
我正在尝试将所有 json 文件存储在 blob 存储的子文件夹中的单个容器中。我已经在数据块中设置了环境并链接了连接。目前我正在使用此代码
df = spark.read.json("wasbs://container_name@blob_storage_account.blob.core.windows.net/sub_folder/*.json")
但我得到的只是第一个文件,而不是子文件夹中存在的所有 json 文件,即使在包含通配符之后也是如此/*.json
。
我正在尝试从单个数据框中的子文件夹中获取所有文件,并将其作为表存储在 sql 数据库中。
有人可以帮助解决我所缺少的。
解决方案
I have tested in my environment.
I have 3 json blob files inside the subfolder of my container in storage account. I am able to read all the blob json files in a single data frame
You can use the below code to display all json the files from the subfolder in a single data frame
df = spark.read.json("wasbs://container_name@blob_storage_account.blob.core.windows.net/sub_folder/*.json")
df.show()
推荐阅读
- ios - 在后台线程上与领域数据库交互
- javascript - 如何在 mac 上使用 Ajax 将 Javascript 变量发送到 PHP?
- c - 有人可以帮助如何在函数中返回每个数组,然后在主函数中调用它吗?[C]
- python - 如果满足条件,则在 pandas 数据框中进行数学运算
- java - 如何在没有字段、参数或返回类型的情况下跨方法发送数据?
- angular - 渴望加载一个离子吐司控制器
- javascript - 尝试使用 REST API 调用生成的 javascript 数组填充下拉框时出错
- r - 根据 R 中的列名创建一个新数据框,其中包含来自另一个数据框的列
- sql - 从逗号分隔的数据进行 SQL 更新
- powershell - 从 Confluence 页面获取限制