Reputation: 3623
I am using PySpark to read a csv file. Below is my simple code.
from pyspark.sql.session import SparkSession
def predict_metrics():
session = SparkSession.builder.master('local').appName("PredictFacebookMetrics").getOrCreate()
dataframe = session.read().format('com.databricks.spark.csv') \
.option('header', True) \
.option('delimiter', ';') \
.option('inferSchema', True) \
.load(r'D:\M\Facebook_metrics_data\dataset_Facebook.csv')
dataframe.printSchema()
dataframe.show(False)
if __name__=='__main__':
predict_metrics()
Upon executing above code I get the following error:
TypeError: 'DataFrameReader' object is not callable
What is the solution to this error?
Upvotes: 5
Views: 12308
Reputation: 3623
As suggested in comment,
It should be session.read.format
instead of session.read().format
Silly Me!
Upvotes: 8