Question: how to convert csv file into dataframe in spark?
Answer: Do it in a programmatic way. val df = spark. read . format("csv") . option("header", "true") //first line in file has headers . ... 
You can do this SQL way as well. val df = spark. sql("SELECT * FROM csv.` hdfs:///csv/file/dir/file.csv`") Dependencies: "org.apache.spark" % "spark-core_2.11" % 2.0.