I am having a dataframe which has some multi-line observations:
+--------------------+----------------+ | col1| col2| +--------------------+----------------+ |something1 |somethingelse1 | |something2 |somethingelse2 | |something3 |somethingelse3 | |something4 |somethingelse4 | |multiline row | somethings| |something |somethingall | What I want is to save in csv format(or txt) this dataframe. Using the following:
df .write .format("csv") .save("s3://../adf/") 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:
df .as[(String,String)] .rdd .saveAsTextFile("s3://../adf") but the same output was observed.
I can imagine that one way is to replace \n 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?