【发布时间】:2021-02-02 09:56:24
【问题描述】:
我需要将多个 JSON 文件读入 spark df。 JSON 数据如下所示:
{"f0_":{"id":"138307057680","ActionName":"Complete","Time":"2020-04-23-12:40:04"}}
{"f0_":{"id":"138313115245","ActionName":"Midpoint","Time":"2020-06-16-20:41:16"}}
我需要去掉包含所有列的第一个键。 我试过了:
jsonFiles = spark.read.json("Resources") # path to all json files
jsonFile.printSchema()
输出是:
root
|-- f0_: struct (nullable = true)
| |-- id string (nullable = true)
| |-- ActionName: string (nullable = true)
| |-- Time: string (nullable = true)
【问题讨论】:
-
你试过
select('f0_.*')吗? -
我没有。 select(f0_.*) 的语法是什么?
-
所有数据框都有一个选择功能,这里显示spark.apache.org/docs/2.2.0/…
-
那行得通。谢谢!
标签: json apache-spark pyspark