<?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: What is the best way to export Hive table containing many null values to CSV ? in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/What-is-the-best-way-to-export-Hive-table-containing-many/m-p/146758#M48474</link>
    <description>&lt;P&gt;You cannot do this directly from the export command and must do some separate processing.&lt;/P&gt;&lt;P&gt;I feel the best way to do this is to run this pig script on export result&lt;/P&gt;&lt;PRE&gt;raw = load 'data.csv' using PigStorage(',');
nonull = foreach raw generate 
	REPLACE($0, '\\\\N', ''),
	REPLACE($1, '\\\\N', ''),
	REPLACE($2, '\\\\N', ''),
	REPLACE($3, '\\\\N', '');
store nonull into 'nonull/data.csv' using PigStorage(',');&lt;/PRE&gt;&lt;P&gt;Keep in mind this will result in output in the m-r format in hdfs&lt;/P&gt;&lt;PRE&gt;data.csv
data.csv/_SUCCESS
data.csv/part-m-00000
data.csv/part-m-00001
...&lt;/PRE&gt;&lt;P&gt;If you want to process this file in hadoop, just point to data.csv&lt;/P&gt;&lt;P&gt;If you want to pull this to edge node with command line use hdfs dfs -getmerge &amp;lt;localpath&amp;gt; nonull/data.csv&lt;/P&gt;&lt;P&gt;If you want to download it using Ambari Files View, just double click on nonull/data.csv the click Select All then Concatenate and it will download as a single file&lt;/P&gt;</description>
    <pubDate>Fri, 09 Dec 2016 23:25:17 GMT</pubDate>
    <dc:creator>gkeys</dc:creator>
    <dc:date>2016-12-09T23:25:17Z</dc:date>
    <item>
      <title>What is the best way to export Hive table containing many null values to CSV ?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/What-is-the-best-way-to-export-Hive-table-containing-many/m-p/146757#M48473</link>
      <description>&lt;P&gt;I tried specifying what Hive must use as null values for the export but it keeps writing out the physical values in the CSV file as "NULL" or "\N' where I need to be empty values just separated by ,. E.g. file line is currently written as W,\N,\N,\N where I need format of W,,,&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2016 22:22:47 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/What-is-the-best-way-to-export-Hive-table-containing-many/m-p/146757#M48473</guid>
      <dc:creator>willem_conradie</dc:creator>
      <dc:date>2016-12-09T22:22:47Z</dc:date>
    </item>
    <item>
      <title>Re: What is the best way to export Hive table containing many null values to CSV ?</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/What-is-the-best-way-to-export-Hive-table-containing-many/m-p/146758#M48474</link>
      <description>&lt;P&gt;You cannot do this directly from the export command and must do some separate processing.&lt;/P&gt;&lt;P&gt;I feel the best way to do this is to run this pig script on export result&lt;/P&gt;&lt;PRE&gt;raw = load 'data.csv' using PigStorage(',');
nonull = foreach raw generate 
	REPLACE($0, '\\\\N', ''),
	REPLACE($1, '\\\\N', ''),
	REPLACE($2, '\\\\N', ''),
	REPLACE($3, '\\\\N', '');
store nonull into 'nonull/data.csv' using PigStorage(',');&lt;/PRE&gt;&lt;P&gt;Keep in mind this will result in output in the m-r format in hdfs&lt;/P&gt;&lt;PRE&gt;data.csv
data.csv/_SUCCESS
data.csv/part-m-00000
data.csv/part-m-00001
...&lt;/PRE&gt;&lt;P&gt;If you want to process this file in hadoop, just point to data.csv&lt;/P&gt;&lt;P&gt;If you want to pull this to edge node with command line use hdfs dfs -getmerge &amp;lt;localpath&amp;gt; nonull/data.csv&lt;/P&gt;&lt;P&gt;If you want to download it using Ambari Files View, just double click on nonull/data.csv the click Select All then Concatenate and it will download as a single file&lt;/P&gt;</description>
      <pubDate>Fri, 09 Dec 2016 23:25:17 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/What-is-the-best-way-to-export-Hive-table-containing-many/m-p/146758#M48474</guid>
      <dc:creator>gkeys</dc:creator>
      <dc:date>2016-12-09T23:25:17Z</dc:date>
    </item>
  </channel>
</rss>

