_corrupt_record error when reading a JSON file into Spark

后端 未结 5 2010
清酒与你
清酒与你 2020-12-05 22:57

I\'ve got this JSON file

{
    "a": 1, 
    "b": 2
}

which has been obtained with Python json.dump method. Now, I want to

5条回答
  •  遥遥无期
    2020-12-05 23:37

    If you want to leave your JSON file as it is (without stripping new lines characters \n), include multiLine=True keyword argument

    sc = SparkContext() 
    sqlc = SQLContext(sc)
    
    df = sqlc.read.json('my_file.json', multiLine=True)
    
    print df.show()
    

提交回复
热议问题