[ Skip to the content ]

Institute of Formal and Applied Linguistics Wiki


[ Back to the navigation ]

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
spark:recipes:writing-text-files [2014/11/04 14:40]
straka
spark:recipes:writing-text-files [2014/11/04 14:59] (current)
straka
Line 39: Line 39:
  
 ===== Writing Text Files by Paragraphs  ===== ===== Writing Text Files by Paragraphs  =====
 +
 +The ''saveAsTextFile'' method always writes one newline between elements. If you want to separate elements by two newlines, append a newline to every element manually:
 +<file python>
 +lines.map(lambda line: str(line) + "\n").saveAsTextFile("output_path")
 +</file>
 +<file scala>
 +lines.map(_.toString + "\n").saveAsTextFile("output_path")
 +</file>
  

[ Back to the navigation ] [ Back to the content ]