text: 53976/scala-save-filtered-data-row-by-row-using-saveastextfile
  Hello Team,
  I want to save filtered data row by row using saveAsTextFile. Kindly help.
  I tried with flatmap but it's flattening every column.
  val rdd1=sc.textFile("/user/edureka_40114/AppleStore.csv")
  val rdd3=apple.map(x=>x.split(",")).filter(x=>x(12).equals("\"Games\"")).map(x=>(x(0),x(1)))
  rdd3.collect()
  I want the output to be saved in hdfs file as below but using flatmap it's giving everything in a separate line.
  "1","281656475"
  "6","283619399"
  "10","284736660"
  Try this code, it worked for me:
  val sqlContext = new org.apache.spark.sql.SQLContext(sc)
  import sqlContext.implicits._
  val data = sqlContext.read.format("csv").option("header", "false").load("/user/edureka_425640/AppleStore.csv")
  data.write.format("csv").save("mobil_out")
  Check the reference code mentioned below:
  def main(args: ...READ MORE
  Please refer to the below code as ...READ MORE
  Hi,
  Yes, "foreach" function you use because it will ...READ MORE
  Did you find any documents or
  Try this and see if this does ...READ MORE
  Converting text file to Orc:
  Using Spark, the ...READ MORE
  OR
  Already have an account? Sign in.