I'm trying to read a CSV file in spark using spark df. The file doesn't have a header column but I want to have the header column. How to do that? I don't know if I'm correct or not, I wrote this command -> val df = spark.read.format("csv").load("/path/genchan1.txt").show()
and got the column name as _c0 and _c1 for columns. Then I tried to change the column name to the desired names using: val df1 = df.withColumnRenamed("_c0","Series") , But I'm getting "withColumnRenamed" is not a member on unit.
PS: I have imported spark.implicits._ and spark.sql.functions already.
Please help me know is there any way to add a column header to dataset and why I'm getting this issue.