I have a file in JSON Lines format with the following content:
[1, "James", 21, "M", "2016-04-07 10:25:09"]
[2, "Liz", 25, "F", "2017-05-07 20:25:09"]
...
Each line is a JSON array string, and the types of fields are: integer、string、integer、string、string. How to convert it to a DataFrame
with the following schema?
root
|-- id: integer (nullable = true)
|-- name: string (nullable = true)
|-- age: integer (nullable = true)
|-- gender: string (nullable = true)
|-- time: string (nullable = true)
On the contrary, if I have a DataFrame
with the above schema, how to generate a file like the above JSON Lines format?