<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: HDPCD-Spark: How to convert DF to CSV file? in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/HDPCD-Spark-How-to-convert-DF-to-CSV-file/m-p/158040#M53238</link>
    <description>&lt;P&gt;You have to convert the DF to a table, then save the table like: &lt;/P&gt;&lt;PRE&gt;myDF.registerTempTable("myTempTable")
val myDFTable = sqlContext.sql("SELECT col1, col2, col3 FROM myTempTable WHERE col2 &amp;gt; 1000")
myDFTable.map(x =&amp;gt; x(0) + "," + x(1) + "," + x(2)).saveAsTextFile("output.csv")&lt;/PRE&gt;</description>
    <pubDate>Sat, 04 Feb 2017 00:44:20 GMT</pubDate>
    <dc:creator>wgonzalez</dc:creator>
    <dc:date>2017-02-04T00:44:20Z</dc:date>
    <item>
      <title>HDPCD-Spark: How to convert DF to CSV file?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/HDPCD-Spark-How-to-convert-DF-to-CSV-file/m-p/158039#M53237</link>
      <description>&lt;P&gt;As we know that, due to restricted environment for HDPCD-Spark exam, can't download any 3rd party jars.&lt;/P&gt;&lt;P&gt;And as we also know that, we can save/load DF to/from JSON/ORC/PARQUET file formats.&lt;/P&gt;&lt;P&gt;However, there is an issue with CSV files.&lt;/P&gt;&lt;P&gt;Hence, my question is that:&lt;/P&gt;&lt;P&gt;How to save the DataFrame to a CSV file using pure Spark Core or Spark SQL APIs? &amp;amp; vice-a-versa.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Feb 2017 01:26:58 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/HDPCD-Spark-How-to-convert-DF-to-CSV-file/m-p/158039#M53237</guid>
      <dc:creator>bkabhijit</dc:creator>
      <dc:date>2017-02-03T01:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: HDPCD-Spark: How to convert DF to CSV file?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/HDPCD-Spark-How-to-convert-DF-to-CSV-file/m-p/158040#M53238</link>
      <description>&lt;P&gt;You have to convert the DF to a table, then save the table like: &lt;/P&gt;&lt;PRE&gt;myDF.registerTempTable("myTempTable")
val myDFTable = sqlContext.sql("SELECT col1, col2, col3 FROM myTempTable WHERE col2 &amp;gt; 1000")
myDFTable.map(x =&amp;gt; x(0) + "," + x(1) + "," + x(2)).saveAsTextFile("output.csv")&lt;/PRE&gt;</description>
      <pubDate>Sat, 04 Feb 2017 00:44:20 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/HDPCD-Spark-How-to-convert-DF-to-CSV-file/m-p/158040#M53238</guid>
      <dc:creator>wgonzalez</dc:creator>
      <dc:date>2017-02-04T00:44:20Z</dc:date>
    </item>
  </channel>
</rss>

