<?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>idea Table to Excel - Null values in ArcGIS Pro Ideas</title>
    <link>https://community.esri.com/t5/arcgis-pro-ideas/table-to-excel-null-values/idi-p/1354729</link>
    <description>&lt;P&gt;&lt;STRONG&gt;Idea:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;In the &lt;U&gt;Table to Excel&lt;/U&gt; tool, add a parameter to specify the value that the tool will write to any cell that has a NULL value in the original table (e.g., a "sentinel value").&lt;/P&gt;&lt;P&gt;Optionally, there could also be multiple parameters for specifying different sentinel values for each possible data type, but this might likely be overkill.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The Problem:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;As we all (likely) know, Excel has no real concept of a NULL value.&amp;nbsp; Currently, when you run Table to Excel, it effectively just doesn't write to those cells, which means depending on what you're doing with the final file, Excel might read that as a 0 or an empty string ("").&lt;/P&gt;&lt;P&gt;There's not really a clean and easy way to replace these "fake nulls" after export (especially if your data has a mixture of legitimate zeroes and NULLs, for example) and it seems like a tedious waste of time &amp;amp; effort to make a copy of this table, manually change all those NULLs to a sentinel value, and then finally run Table to Excel.&lt;/P&gt;&lt;P&gt;Given my limited experience with Python's excel libraries, this seems like something that should be able to handled by the conversion engine(s) on the back end at the time that they're writing the Excel file.&lt;/P&gt;&lt;P&gt;I'm tempted to write up a script myself, but given that it feels a bit like reinventing the wheel at that point, I thought I should raise the Idea so everyone could benefit.&lt;/P&gt;</description>
    <pubDate>Wed, 29 Nov 2023 17:42:03 GMT</pubDate>
    <dc:creator>MErikReedAugusta</dc:creator>
    <dc:date>2023-11-29T17:42:03Z</dc:date>
    <item>
      <title>Table to Excel - Null values</title>
      <link>https://community.esri.com/t5/arcgis-pro-ideas/table-to-excel-null-values/idi-p/1354729</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Idea:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;In the &lt;U&gt;Table to Excel&lt;/U&gt; tool, add a parameter to specify the value that the tool will write to any cell that has a NULL value in the original table (e.g., a "sentinel value").&lt;/P&gt;&lt;P&gt;Optionally, there could also be multiple parameters for specifying different sentinel values for each possible data type, but this might likely be overkill.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The Problem:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;As we all (likely) know, Excel has no real concept of a NULL value.&amp;nbsp; Currently, when you run Table to Excel, it effectively just doesn't write to those cells, which means depending on what you're doing with the final file, Excel might read that as a 0 or an empty string ("").&lt;/P&gt;&lt;P&gt;There's not really a clean and easy way to replace these "fake nulls" after export (especially if your data has a mixture of legitimate zeroes and NULLs, for example) and it seems like a tedious waste of time &amp;amp; effort to make a copy of this table, manually change all those NULLs to a sentinel value, and then finally run Table to Excel.&lt;/P&gt;&lt;P&gt;Given my limited experience with Python's excel libraries, this seems like something that should be able to handled by the conversion engine(s) on the back end at the time that they're writing the Excel file.&lt;/P&gt;&lt;P&gt;I'm tempted to write up a script myself, but given that it feels a bit like reinventing the wheel at that point, I thought I should raise the Idea so everyone could benefit.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 17:42:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-ideas/table-to-excel-null-values/idi-p/1354729</guid>
      <dc:creator>MErikReedAugusta</dc:creator>
      <dc:date>2023-11-29T17:42:03Z</dc:date>
    </item>
    <item>
      <title>Re: Table to Excel - Null values</title>
      <link>https://community.esri.com/t5/arcgis-pro-ideas/table-to-excel-null-values/idc-p/1354887#M27298</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/569244"&gt;@MErikReedAugusta&lt;/a&gt;&amp;nbsp;Maybe this script can help you with the null string fields? Here is the doc link for other datatypes besides string if you want to do it for numerics or dates.&lt;BR /&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/listfields.htm" target="_blank"&gt;ListFields—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
sentinel_for_string = "sentinel"
table_path = "c:/data/municipal.gdb/hospitals"
# https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/listfields.htm
fields = arcpy.ListFields(table_path, field_type="String") 
tab = arcpy.management.CopyRows(table_path, "memory\\t_hospitals")[0]
field_names = [f.name for f in fields]
ftype = ["TEXT"] * len(field_names)
fname = [f"{i}_" for i in field_names]
calculation = [f"\"{sentinel_for_string}\""] * len(field_names)
where = [f"{i} IS NULL" for i in field_names]
exp = list(zip(fname, calculation, where))
arcpy.management.AddFields(tab, list(zip(fname, ftype)))
arcpy.management.CalculateFields(tab,
                                "PYTHON3",
                                exp)
arcpy.conversion.TableToExcel(tab, "c:/data/hospitals.xlsx")&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 21:16:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-ideas/table-to-excel-null-values/idc-p/1354887#M27298</guid>
      <dc:creator>JonathanNeal</dc:creator>
      <dc:date>2023-11-29T21:16:56Z</dc:date>
    </item>
    <item>
      <title>Re: Table to Excel - Null values</title>
      <link>https://community.esri.com/t5/arcgis-pro-ideas/table-to-excel-null-values/idc-p/1354891#M27299</link>
      <description>&lt;P&gt;Worth noting that the first thing that jumps out at me is that this currently relies on adding a field, which isn't always an option.&lt;/P&gt;&lt;P&gt;And as I pointed out in my original post, I could almost certainly write a bespoke script to take care of this (without adding a field, if needed), but I felt that since it's such a basic issue when converting between Tables &amp;amp; Excel, that everyone sooner or later will likely run into it, and there was value in a solution at the ArcGIS level.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 21:30:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-ideas/table-to-excel-null-values/idc-p/1354891#M27299</guid>
      <dc:creator>MErikReedAugusta</dc:creator>
      <dc:date>2023-11-29T21:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: Table to Excel - Null values</title>
      <link>https://community.esri.com/t5/arcgis-pro-ideas/table-to-excel-null-values/idc-p/1354900#M27302</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/569244"&gt;@MErikReedAugusta&lt;/a&gt;&amp;nbsp;Not necessary to add the fields, or make a memory table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I put those there so you can compare the results, just in case, so you don't overwrite the data.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Your idea is still valid, so keep the kudos coming and we'll bring it into a release.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 21:45:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-ideas/table-to-excel-null-values/idc-p/1354900#M27302</guid>
      <dc:creator>JonathanNeal</dc:creator>
      <dc:date>2023-11-29T21:45:39Z</dc:date>
    </item>
  </channel>
</rss>

