Issue with writing DF to textFile - Text Data supports only single column

Hi Everyone,

I was working on CCA problem 7 and I was trying to write the output of DF to a textfile as mentioned below


I faced the following issue

Traceback (most recent call last):
pyspark.sql.utils.AnalysisException: u’Text data source supports only a single column, and you have 4 columns.;'

Were any one able to convert df to textfile . Appreciate your response


1 Like

This is a method to do it.
val res=df.coalesce(1).rdd>x.getString(0)).saveAsTextFile(“user/ansh1307/spark_practice/problem5/data/untraded_stocks”)

but when asked to save a text file you can use csv file format