Pyspark – Export DataFrame to Text

Your attempt with the csv method was almost correct, you only need to change the delimiter from the default (comma) to tab:

df.write.option("sep", "\t").csv("output_file")

Note that CSV is actually a text format (you can view it with a text editor; it contains tabular data where rows are separated by new line characters, and fields are separated by commas). The tab-delimited variation of it is sometimes called TSV.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top