I am trying to read a text file in spark 2.3 using python,but I get this error. This is the format textFile is in:
name marks
amar 100
babul 70
ram 98
krish 45
Code:
df=spark.read.option("header","true")\
.option("delimiter"," ")\
.option("inferSchema","true")\
.schema(
StructType(
[
StructField("Name",StringType()),
StructField("marks",IntegerType())
]
)
)\
.text("file:/home/maria_dev/prac.txt")
Error:
java.lang.AssertionError: assertion failed: Text data source only produces a single data column named "value"
While I am trying to read a textFile into an RDD, its being collected as a single column.
Should the data file should be changed or shoud I change my code?