'DataFrameReader' object has no attribute 'csv'

Hi,

I’m executing below code:

from pyspark.sql import SQLContext
sqlContext = SQLContext(sc)
df = spark.read.csv("/home/training/Downloads/bank.csv", header=True, inferSchema=True)
df.PrintSchema()

That gives me below error:

df = sqlContext.read.csv(SparkFiles.get(“adult_data.csv”), header=True, inferSchema= True)
Traceback (most recent call last):
File “”, line 1, in
AttributeError: ‘DataFrameReader’ object has no attribute ‘csv’

Any help would be appreciated.

Learn Spark 1.6.x or Spark 2.x on our state of the art big data labs

  • Click here for access to state of the art 13 node Hadoop and Spark Cluster