title: How to handle multi line rows in spark?
body: <p>I am having a dataframe which has some multi-line observations:</p>
  
  <pre><code>+--------------------+----------------+
  |         col1|               col2|
  +--------------------+----------------+
  |something1           |somethingelse1  |
  |something2           |somethingelse2  |
  |something3           |somethingelse3  |
  |something4           |somethingelse4  |
  |multiline
  
   row               |     somethings|
  |something            |somethingall    |
  </code></pre>
  
  <p>What I want is to save in <code>csv</code> format(or <code>txt</code>) this dataframe. Using the following:</p>
  
  <pre><code>df
   .write
   .format("csv")
   .save("s3://../adf/")
  </code></pre>
  
  <p>But when I check the file it seperates the observations to multiple lines. What I want is the lines that have 'multiline' observatios to be one the same row in the txt/csv file. I tried to save it as txt file:</p>
  
  <pre><code>df
  .as[(String,String)]
  .rdd
  .saveAsTextFile("s3://../adf")
  </code></pre>
  
  <p>but the same output was observed. </p>
  
  <p>I can imagine that one way is to replace <code>\n</code> with something else and after when loading back do the reverse function. But Is there a way to save it in the desired way without doing any kind of transformation to the data?</p>