cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to write my dataframe out as a tab separated .txt file but getting an error

User16826992666
Valued Contributor

When I try to save my file I get

org.apache.spark.sql.AnalysisException: Text data source supports only a single column, and you have 2 columns.;

Is there any way to save a dataframe with more than one column to a .txt file?

1 REPLY 1

sajith_appukutt
Honored Contributor II

Would pyspark.sql.DataFrameWriter.csv work? You could specify the separator (sep) as tab

df.write.csv(os.path.join(tempfile.mkdtemp(), 'data'))

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.