<?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>topic Re: Query results in csv file include 'null' string for blank cell in Get Started Discussions</title>
    <link>https://community.databricks.com/t5/get-started-discussions/query-results-in-csv-file-include-null-string-for-blank-cell/m-p/105648#M9551</link>
    <description>&lt;P&gt;Also running into this, for fields with date datatype&lt;/P&gt;&lt;P&gt;NULL values end up with "null" strings in the downloaded csv file along with actual dates. This causes import problems when trying to load into other systems and the field is defined as date.&amp;nbsp;&lt;/P&gt;&lt;P&gt;only solution is to cast null to a default date value like - '1900-01-01' in the query but this is not ideal. Would love a better built-in solution!&lt;/P&gt;</description>
    <pubDate>Tue, 14 Jan 2025 21:58:55 GMT</pubDate>
    <dc:creator>Gabriel2</dc:creator>
    <dc:date>2025-01-14T21:58:55Z</dc:date>
    <item>
      <title>Query results in csv file include 'null' string for blank cell</title>
      <link>https://community.databricks.com/t5/get-started-discussions/query-results-in-csv-file-include-null-string-for-blank-cell/m-p/55456#M9547</link>
      <description>&lt;P&gt;After running a sql script, when downloading the results to a csv file, the file includes a&amp;nbsp;&lt;STRONG&gt;null&lt;/STRONG&gt; string for blank cells (see screenshot). Is ther a setting I can change to simply get empty cells instead?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlexG_1-1702927614092.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/5633iD856FBB4E7EBC71B/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="AlexG_1-1702927614092.png" alt="AlexG_1-1702927614092.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Dec 2023 19:31:46 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/query-results-in-csv-file-include-null-string-for-blank-cell/m-p/55456#M9547</guid>
      <dc:creator>AlexG</dc:creator>
      <dc:date>2023-12-18T19:31:46Z</dc:date>
    </item>
    <item>
      <title>Re: Query results in csv file include 'null' string for blank cell</title>
      <link>https://community.databricks.com/t5/get-started-discussions/query-results-in-csv-file-include-null-string-for-blank-cell/m-p/58441#M9548</link>
      <description>&lt;P&gt;You need to use "emptyValue" when writing you data&lt;/P&gt;
&lt;PRE class="lang-py s-code-block"&gt;&lt;CODE class="hljs language-python"&gt;df.write.csv(PATH, header=&lt;SPAN class="hljs-literal"&gt;True&lt;/SPAN&gt;, emptyValue=&lt;SPAN class="hljs-string"&gt;''&lt;/SPAN&gt;)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; Here is a list of APIs references&amp;nbsp;&lt;A href="https://spark.apache.org/docs/latest/sql-data-sources-csv.html" target="_blank"&gt;https://spark.apache.org/docs/latest/sql-data-sources-csv.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2024 17:46:59 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/query-results-in-csv-file-include-null-string-for-blank-cell/m-p/58441#M9548</guid>
      <dc:creator>jose_gonzalez</dc:creator>
      <dc:date>2024-01-25T17:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: Query results in csv file include 'null' string for blank cell</title>
      <link>https://community.databricks.com/t5/get-started-discussions/query-results-in-csv-file-include-null-string-for-blank-cell/m-p/67408#M9549</link>
      <description>&lt;P&gt;Thank you. How would you download to csv the results from a SQL script without the&amp;nbsp;&lt;STRONG&gt;null&lt;/STRONG&gt; strings in empty cells?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlexG_1-1714142384717.png" style="width: 999px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/7280i9F6E889CED0052EF/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999" role="button" title="AlexG_1-1714142384717.png" alt="AlexG_1-1714142384717.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I mainly work with SQL notebooks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2024 14:42:16 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/query-results-in-csv-file-include-null-string-for-blank-cell/m-p/67408#M9549</guid>
      <dc:creator>AlexG</dc:creator>
      <dc:date>2024-04-26T14:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: Query results in csv file include 'null' string for blank cell</title>
      <link>https://community.databricks.com/t5/get-started-discussions/query-results-in-csv-file-include-null-string-for-blank-cell/m-p/67777#M9550</link>
      <description>&lt;P&gt;Hi &lt;A id="link_7" class="lia-link-navigation lia-page-link lia-user-name-link" href="https://community.databricks.com/t5/user/viewprofilepage/user-id/87766" target="_self" aria-label="View Profile of AlexG"&gt;&lt;SPAN class=""&gt;AlexG&lt;/SPAN&gt;&lt;/A&gt;,&lt;/P&gt;
&lt;P&gt;I tested with the table content containing null and with empty data and it works as expected in the download option too.&lt;/P&gt;
&lt;P&gt;Here is an eg:&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;LI-CODE lang="markup"&gt;CREATE TABLE my_table_null_test1 (
id INT,
name STRING
);

INSERT INTO my_table_null_test1 (id, name) VALUES
(1, 'John Doe'),
(2, NULL),
(3, 'Jane Doe'),
(NULL, 'Anonymous')
(4, '');&lt;/LI-CODE&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-05-01 at 11.31.00.png" style="width: 999px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/7341i1AD81DD4405DD3DD/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2024-05-01 at 11.31.00.png" alt="Screenshot 2024-05-01 at 11.31.00.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;If you do not want nulls, you may have to modify the query to use&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;SPAN class="k"&gt;coalesce&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="k"&gt;NULL&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; ''&lt;SPAN class="p"&gt;) or&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;SPAN class="n"&gt;nvl&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="k"&gt;NULL&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; ''&lt;SPAN class="p"&gt;);&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Hope it helps. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2024 06:03:40 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/query-results-in-csv-file-include-null-string-for-blank-cell/m-p/67777#M9550</guid>
      <dc:creator>NandiniN</dc:creator>
      <dc:date>2024-05-01T06:03:40Z</dc:date>
    </item>
    <item>
      <title>Re: Query results in csv file include 'null' string for blank cell</title>
      <link>https://community.databricks.com/t5/get-started-discussions/query-results-in-csv-file-include-null-string-for-blank-cell/m-p/105648#M9551</link>
      <description>&lt;P&gt;Also running into this, for fields with date datatype&lt;/P&gt;&lt;P&gt;NULL values end up with "null" strings in the downloaded csv file along with actual dates. This causes import problems when trying to load into other systems and the field is defined as date.&amp;nbsp;&lt;/P&gt;&lt;P&gt;only solution is to cast null to a default date value like - '1900-01-01' in the query but this is not ideal. Would love a better built-in solution!&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 21:58:55 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/query-results-in-csv-file-include-null-string-for-blank-cell/m-p/105648#M9551</guid>
      <dc:creator>Gabriel2</dc:creator>
      <dc:date>2025-01-14T21:58:55Z</dc:date>
    </item>
    <item>
      <title>Re: Query results in csv file include 'null' string for blank cell</title>
      <link>https://community.databricks.com/t5/get-started-discussions/query-results-in-csv-file-include-null-string-for-blank-cell/m-p/106063#M9552</link>
      <description>&lt;P&gt;I understand, however this is more on CSV file format.&amp;nbsp;&lt;/P&gt;
&lt;P dir="ltr"&gt;&lt;SPAN&gt;Save your data in Delta format instead of CSV or text-based formats. Delta tables handle empty strings and&amp;nbsp;&lt;CODE&gt;NULL&lt;/CODE&gt; values more effectively, ensuring that empty strings are preserved during data insertion.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://kb.databricks.com/en_US/data/empty-string-values-convert-to-null-values-when-saving-a-table-as-csv-or-text-based-file-format" target="_blank"&gt;https://kb.databricks.com/en_US/data/empty-string-values-convert-to-null-values-when-saving-a-table-as-csv-or-text-based-file-format&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2025 11:15:41 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/query-results-in-csv-file-include-null-string-for-blank-cell/m-p/106063#M9552</guid>
      <dc:creator>NandiniN</dc:creator>
      <dc:date>2025-01-17T11:15:41Z</dc:date>
    </item>
  </channel>
</rss>

