smile
smile

Reputation: 21

AttributeError: 'SQLContext' object has no attribute 'jsonFile'

When I perform the following actions.I met this problem in centos 7.0 and spark 2.1.0. I am a freshman in spark. How to fix it?

>>> from pyspark.sql import SQLContext
>>> ssc = SQLContext(sc)
>>> df = ssc.jsonFile('file:///root/work/person.json')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'SQLContext' object has no attribute 'jsonFile'

Upvotes: 2

Views: 4107

Answers (2)

Avishkar Meshram
Avishkar Meshram

Reputation: 51

jsonFile has been deprecated, please use sqlContext.read.json

Upvotes: 0

koiralo
koiralo

Reputation: 23109

Use SparkSession with the newer version of Spark and read using df = spark.read.json('path to json).

Upvotes: 2

Related Questions