【发布时间】:2022-01-29 20:42:26
【问题描述】:
我有一个csv 文件,其中包含这样的数据
ID|Arr_of_Str
1|["ABC DEF"]
2|["PQR", "ABC DEF"]
我想读取这个.csv 文件,但是当我使用sqlContext.read.load 时,它会以字符串的形式读取它
当前:
df.printSchema()
root
|-- ID: integer (nullable = true)
|-- Arr_of_Str: string (nullable = true)
预期:
df.printSchema()
root
|-- ID: integer (nullable = true)
|-- Arr_of_Str: array (nullable = true)
|-- element: string (containsNull = true)
如何将字符串转换为字符串数组?
【问题讨论】:
标签: apache-spark pyspark apache-spark-sql