<?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: Forward slashes break map addDataFromPath method in ArcGIS Pro 2.4.0 in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/forward-slashes-break-map-adddatafrompath-method/m-p/1004848#M59125</link>
    <description>&lt;P&gt;&lt;A href="https://support.esri.com/en/bugs/nimbus/TklNMDAwOTY3" target="_blank"&gt;NIM000967: Geoprocessing tools do not recognize a layer name wi.. (esri.com)&lt;/A&gt;&amp;nbsp;but you weren't using geoprocessing tools&lt;/P&gt;</description>
    <pubDate>Wed, 25 Nov 2020 21:52:34 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2020-11-25T21:52:34Z</dc:date>
    <item>
      <title>Forward slashes break map addDataFromPath method in ArcGIS Pro 2.4.0</title>
      <link>https://community.esri.com/t5/python-questions/forward-slashes-break-map-adddatafrompath-method/m-p/1004760#M59123</link>
      <description>&lt;P&gt;Hi Folks,&lt;/P&gt;&lt;P&gt;In ArcGIS Pro 2.4.0, I noticed some unexpected behavior with forward slashes in data paths with code run in the Python console embedded in Pro.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In short, if backslashes are used, the code works:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;d = "C:\gispy\data\ch02\park.shp"
proj = arcpy.mp.ArcGISProject("CURRENT")
m = proj.listMaps()[0]
m.addDataFromPath(d)
&amp;lt;arcpy._mp.Layer object at 0x00000287876AE7F0&amp;gt;
# Hurray! Data added to map.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But if forward slashes are used in the data path, it throws a RuntimError and fails to add data to the map:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;d2 = "C:/gispy/data/ch02/park.shp"
m.addDataFromPath(d2)
Traceback (most recent call last):
File "&amp;lt;string&amp;gt;", line 1, in &amp;lt;module&amp;gt;
File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\_mp.py", line 1531, in addDataFromPath
  return convertArcObjectToPythonObject(self._arc_object.addDataFromPath(*gp_fixargs((data_path,), True)))
RuntimeError&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I could not find a bug report on this.&amp;nbsp; Are there plans to address this or is this intentional behavior?&amp;nbsp; If so, why?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 18:51:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/forward-slashes-break-map-adddatafrompath-method/m-p/1004760#M59123</guid>
      <dc:creator>LauraTateosian</dc:creator>
      <dc:date>2020-11-25T18:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: Forward slashes break map addDataFromPath method in ArcGIS Pro 2.4.0</title>
      <link>https://community.esri.com/t5/python-questions/forward-slashes-break-map-adddatafrompath-method/m-p/1004789#M59124</link>
      <description>&lt;P&gt;If it was found it is several versions old and a backport won't be provided.&amp;nbsp; You could update to a newer version of arcgis pro to be safe.&lt;/P&gt;&lt;P&gt;If you want, you can go through the release notes for prior versions to see if it was reported as a bug and fixed.&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/get-started/release-notes.htm" target="_blank"&gt;Release notes for ArcGIS Pro 2.6—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The path with forward slashes is python valid, however, to play it safe with back slash paths, always use raw encoding&lt;/P&gt;&lt;LI-CODE lang="python"&gt;good = r"C:\temp\data\ch02\park.shp"  # ---- a little `r` goes a long way
bad = "C:\temp\data\ch02\park.shp"    # ---- no `r`
# ---- test prints
print(good)
C:\temp\data\ch02\park.shp
print(bad)
C:	emp\data\ch02\park.shp  # ---- a tab inserted

# ---- abject total failure
ugly = "C:\temp\data\ch02\x.shp"
  File "&amp;lt;ipython-input-11-6fa7135b60c0&amp;gt;", line 1
    ugly = "C:\temp\data\ch02\x.shp"
          ^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 17-18: truncated \xXX escape&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 25 Nov 2020 19:46:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/forward-slashes-break-map-adddatafrompath-method/m-p/1004789#M59124</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2020-11-25T19:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: Forward slashes break map addDataFromPath method in ArcGIS Pro 2.4.0</title>
      <link>https://community.esri.com/t5/python-questions/forward-slashes-break-map-adddatafrompath-method/m-p/1004848#M59125</link>
      <description>&lt;P&gt;&lt;A href="https://support.esri.com/en/bugs/nimbus/TklNMDAwOTY3" target="_blank"&gt;NIM000967: Geoprocessing tools do not recognize a layer name wi.. (esri.com)&lt;/A&gt;&amp;nbsp;but you weren't using geoprocessing tools&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 21:52:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/forward-slashes-break-map-adddatafrompath-method/m-p/1004848#M59125</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2020-11-25T21:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: Forward slashes break map addDataFromPath method in ArcGIS Pro 2.4.0</title>
      <link>https://community.esri.com/t5/python-questions/forward-slashes-break-map-adddatafrompath-method/m-p/1004917#M59127</link>
      <description>&lt;P&gt;Hi Dan, Great to hear from you.&amp;nbsp; Somehow, I always encounter you when researching arcpy issues online. I feel like I know you. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp; Yes, I'm familiar with the raw string approach and the perils of escape sequences.&amp;nbsp; This is why I found it even more frustrating that Pro is not handling forward slashes correctly.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2020 02:33:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/forward-slashes-break-map-adddatafrompath-method/m-p/1004917#M59127</guid>
      <dc:creator>LauraTateosian</dc:creator>
      <dc:date>2020-11-26T02:33:42Z</dc:date>
    </item>
    <item>
      <title>Re: Forward slashes break map addDataFromPath method in ArcGIS Pro 2.4.0</title>
      <link>https://community.esri.com/t5/python-questions/forward-slashes-break-map-adddatafrompath-method/m-p/1004923#M59129</link>
      <description>&lt;P&gt;Good find! Probably the same underlying issue though.&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;This begs a few questions...This was submitted 14 years ago and the status is&amp;nbsp;&amp;nbsp;"Not in Current Product Plan"?&amp;nbsp; What could this mean? Maybe a new bug report needs to be submitted.&amp;nbsp; &amp;nbsp;Can any old shmo create a bug report?&amp;nbsp; Were they really working on ArcGIS Pro in 2006?&amp;nbsp; Forward slashes have never been a problem before in Desktop, why start now?&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2020 02:43:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/forward-slashes-break-map-adddatafrompath-method/m-p/1004923#M59129</guid>
      <dc:creator>LauraTateosian</dc:creator>
      <dc:date>2020-11-26T02:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: Forward slashes break map addDataFromPath method in ArcGIS Pro 2.4.0</title>
      <link>https://community.esri.com/t5/python-questions/forward-slashes-break-map-adddatafrompath-method/m-p/1004928#M59132</link>
      <description>&lt;P&gt;Laura....&lt;/P&gt;&lt;P&gt;I think any shmo can... however, I have never had any problem with forward slashes.&lt;BR /&gt;My default is "raw" encoding (using the little 'r' in scripts).&lt;BR /&gt;In geoprocessing tools, I don't type... I navigate and select files and let arc* wizardry do its work.&lt;/P&gt;&lt;P&gt;I would investigate further and see whether other paths fail with forward slashes.&amp;nbsp; I am wondering if it just may be that particular folder, or something in the mp module (which I rarely use).&lt;/P&gt;&lt;P&gt;Give it shot and if it is reproduceable, then file a report ... however, the first thing that will be suggested is to upgrade to the latest version (2.6.3)&lt;/P&gt;&lt;P&gt;Good luck!&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2020 02:56:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/forward-slashes-break-map-adddatafrompath-method/m-p/1004928#M59132</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2020-11-26T02:56:07Z</dc:date>
    </item>
    <item>
      <title>Re: Forward slashes break map addDataFromPath method in ArcGIS Pro 2.4.0</title>
      <link>https://community.esri.com/t5/python-questions/forward-slashes-break-map-adddatafrompath-method/m-p/1283757#M67539</link>
      <description>&lt;P&gt;For the record, they solved this problem in later versions of ArcGIS Pro.&amp;nbsp; I just tested the same forward slash example in 2.8 and it works.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;d2 = "C:/gispy/data/ch02/park.shp"
proj = arcpy.mp.ArcGISProject("CURRENT")
m = proj.listMaps()[0]
m.addDataFromPath(d2)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2023 10:32:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/forward-slashes-break-map-adddatafrompath-method/m-p/1283757#M67539</guid>
      <dc:creator>LauraTateosian</dc:creator>
      <dc:date>2023-04-28T10:32:07Z</dc:date>
    </item>
  </channel>
</rss>

