<?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: Iterate though folder and add lyrx to a map in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198431#M65119</link>
    <description>&lt;P&gt;Hey MH84, I can give this a shot. What you are going to need to do is crate a Map object to add the layers to. That can be done through something like this:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;aprx = arcpy.mp.ArcGISProject(&lt;/SPAN&gt;&lt;SPAN class=""&gt;r"C:\Projects\YosemiteNP\Yosemite.aprx"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;m = aprx.listMaps(&lt;SPAN class=""&gt;"Yosemite National Park"&lt;/SPAN&gt;)[&lt;SPAN class=""&gt;0&lt;/SPAN&gt;]&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;once you have a map object ("m" in this case), you should be able to loop through those layers and add them to the map with an addLayer call. That would look something like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;m.addLayer(inLayer)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;I grabbed the first code block from ESRI's docs, the link is below (I also highly recommend checking out other pages on that site, they can be really helpful):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/map-class.htm" target="_blank" rel="noopener"&gt;Map—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 02 Aug 2022 11:07:50 GMT</pubDate>
    <dc:creator>mattkramer</dc:creator>
    <dc:date>2022-08-02T11:07:50Z</dc:date>
    <item>
      <title>Iterate though folder and add lyrx to a map</title>
      <link>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198415#M65117</link>
      <description>&lt;P&gt;I am working with a notebook in ArcGIS Pro and I want to add all .lyrx files within a local folder to a map.&lt;/P&gt;&lt;P&gt;I have set the workspace and created a list with:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = "path to my data"&lt;/P&gt;&lt;P&gt;list_layers = arcpy.ListFiles("*.lyrx")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;which works fine. I have tried to create a for loop to iterate though the list and add the layers to the map in my current project without success.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I realise this is probably easy to do but I can't work it out. Any help would be greatly appreciated!&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 09:21:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198415#M65117</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-02T09:21:59Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate though folder and add lyrx to a map</title>
      <link>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198431#M65119</link>
      <description>&lt;P&gt;Hey MH84, I can give this a shot. What you are going to need to do is crate a Map object to add the layers to. That can be done through something like this:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;aprx = arcpy.mp.ArcGISProject(&lt;/SPAN&gt;&lt;SPAN class=""&gt;r"C:\Projects\YosemiteNP\Yosemite.aprx"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;m = aprx.listMaps(&lt;SPAN class=""&gt;"Yosemite National Park"&lt;/SPAN&gt;)[&lt;SPAN class=""&gt;0&lt;/SPAN&gt;]&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;once you have a map object ("m" in this case), you should be able to loop through those layers and add them to the map with an addLayer call. That would look something like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;m.addLayer(inLayer)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;I grabbed the first code block from ESRI's docs, the link is below (I also highly recommend checking out other pages on that site, they can be really helpful):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/map-class.htm" target="_blank" rel="noopener"&gt;Map—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 11:07:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198431#M65119</guid>
      <dc:creator>mattkramer</dc:creator>
      <dc:date>2022-08-02T11:07:50Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate though folder and add lyrx to a map</title>
      <link>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198463#M65121</link>
      <description>&lt;P&gt;Hey&amp;nbsp;@ mattkramer&lt;/P&gt;&lt;P&gt;So I already have a map object as I've added a single feature from AGOL in the previous part of the program. Adding individual layers/feature etc is ok I just can't get the loop right in this instance. I ran the following:&lt;/P&gt;&lt;P&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")&lt;BR /&gt;aprxMap = aprx.listMaps("Map")[0]&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = "Path to my data"&lt;/P&gt;&lt;P&gt;list_layers = arcpy.ListFiles("*.lyrx")&lt;/P&gt;&lt;P&gt;for layer in list_layers:&lt;BR /&gt;m.addLayer(list_layers)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and receive the following error&lt;/P&gt;&lt;P&gt;ValueError Traceback (most recent call last)&lt;BR /&gt;In [43]:&lt;BR /&gt;Line 8: m.addLayer(list_layers)&lt;/P&gt;&lt;P&gt;File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\utils.py, in fn_:&lt;BR /&gt;Line 191: return fn(*args, **kw)&lt;/P&gt;&lt;P&gt;File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py, in addLayer:&lt;BR /&gt;Line 1843: return convertArcObjectToPythonObject(self._arc_object.addLayer(*gp_fixargs((add_layer_or_layerfile, add_position), True)))&lt;/P&gt;&lt;P&gt;ValueError: ['OS_AnnoPoint.lyrx', 'OS_Area_Buildings.lyrx', 'OS_Area_FeatureCode.lyrx', 'OS_Area_Landform.lyrx', 'OS_Area_NatEnv.lyrx', 'OS_Bnd.lyrx', 'OS_Line.lyrx', 'OS_Line_Landform.lyrx', 'OS_Pnt.lyrx', 'OS_Sym.lyrx']&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 12:53:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198463#M65121</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-02T12:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate though folder and add lyrx to a map</title>
      <link>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198469#M65122</link>
      <description>&lt;P&gt;This works for one .lyrx&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OS_Anno = (r"path to my data")&lt;BR /&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")&lt;BR /&gt;aprxMap = aprx.listMaps("Map")[0]&lt;BR /&gt;aprxMap.addDataFromPath(OS_Anno)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but I want to loop over all layers in the folder and add them&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 13:01:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198469#M65122</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-02T13:01:58Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate though folder and add lyrx to a map</title>
      <link>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198474#M65123</link>
      <description>&lt;P&gt;I've also tried this with the associated error&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = "Path to my data"&lt;/P&gt;&lt;P&gt;list_layers = arcpy.ListFiles("*.lyrx")&lt;/P&gt;&lt;P&gt;for layer in list_layers:&lt;BR /&gt;m.addLayer(layer)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ValueError Traceback (most recent call last)&lt;BR /&gt;In [50]:&lt;BR /&gt;Line 8: m.addLayer(layer)&lt;/P&gt;&lt;P&gt;File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\utils.py, in fn_:&lt;BR /&gt;Line 191: return fn(*args, **kw)&lt;/P&gt;&lt;P&gt;File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py, in addLayer:&lt;BR /&gt;Line 1843: return convertArcObjectToPythonObject(self._arc_object.addLayer(*gp_fixargs((add_layer_or_layerfile, add_position), True)))&lt;/P&gt;&lt;P&gt;ValueError: OS_AnnoPoint.lyrx&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 13:09:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198474#M65123</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-02T13:09:44Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate though folder and add lyrx to a map</title>
      <link>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198478#M65124</link>
      <description>&lt;P&gt;Make sure that the "&lt;SPAN&gt;m.addLayer(layer)" is indented.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Try updating it to look like this:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;for layer in list_layers:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;m.addLayer(layer)&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 13:13:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198478#M65124</guid>
      <dc:creator>mattkramer</dc:creator>
      <dc:date>2022-08-02T13:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate though folder and add lyrx to a map</title>
      <link>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198483#M65125</link>
      <description>&lt;P&gt;It was and it's still throwing a value error.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 13:21:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198483#M65125</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-02T13:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate though folder and add lyrx to a map</title>
      <link>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198488#M65126</link>
      <description>&lt;P&gt;this works&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;import glob&lt;/P&gt;&lt;P&gt;directory = "path to my data"&lt;/P&gt;&lt;P&gt;for filename in glob.iglob(f'{directory}/*'):&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; aprxMap.addDataFromPath(filename)&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 13:25:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198488#M65126</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-02T13:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate though folder and add lyrx to a map</title>
      <link>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198489#M65127</link>
      <description>&lt;P&gt;Try using the full path with the addDataFromPath() method by concatenating the workspace path and layer name:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import os
...
    for layer in list_layers:
         m.addDataFromPath(os.path.join(arcpy.env.workspace, layer))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 13:33:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198489#M65127</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-02T13:33:34Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate though folder and add lyrx to a map</title>
      <link>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198501#M65129</link>
      <description>&lt;P&gt;So I tried this and received a RuntimeError. I think you need to iterate over the file itself to add it to a map rather than a list object if I've understood this correctly&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 13:47:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198501#M65129</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-02T13:47:53Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate though folder and add lyrx to a map</title>
      <link>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198503#M65130</link>
      <description>&lt;P&gt;Correct. In my opinion, the arcpy.listLayers function should probably be used on objects already in an ESRI environment. Since you are adding data from a file path, you should dynamically build the layer source from the data locations (hard coded folder path and loop through layer names).&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 13:51:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198503#M65130</guid>
      <dc:creator>mattkramer</dc:creator>
      <dc:date>2022-08-02T13:51:14Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate though folder and add lyrx to a map</title>
      <link>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198517#M65132</link>
      <description>&lt;P&gt;arcpy.ListFIles() returns a list of strings, for your case:&amp;nbsp; ['OS_AnnoPoint.lyrx', 'OS_Area_Buildings.lyrx', 'OS_Area_FeatureCode.lyrx', 'OS_Area_Landform.lyrx', 'OS_Area_NatEnv.lyrx', 'OS_Bnd.lyrx', 'OS_Line.lyrx', 'OS_Line_Landform.lyrx', 'OS_Pnt.lyrx', 'OS_Sym.lyrx'] .&amp;nbsp; Concatenating like above should give you the full path for each layer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Path to my data\OS_AnnoPoint.lyrx&lt;/P&gt;&lt;P&gt;Path to my data\OS_Area_Buildings.lyrx&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;What did the Runtime error say?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 14:07:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198517#M65132</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-02T14:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate though folder and add lyrx to a map</title>
      <link>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198520#M65134</link>
      <description>&lt;P&gt;RuntimeError Traceback (most recent call last)&lt;BR /&gt;In [82]:&lt;BR /&gt;Line 4: m.addDataFromPath(os.path.join(arcpy.env.workspace, layer))&lt;/P&gt;&lt;P&gt;File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py, in addDataFromPath:&lt;BR /&gt;Line 1971: return convertArcObjectToPythonObject(self._arc_object.addDataFromPath(*gp_fixargs((data_path,), True)))&lt;/P&gt;&lt;P&gt;RuntimeError:&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 14:11:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198520#M65134</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-02T14:11:19Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate though folder and add lyrx to a map</title>
      <link>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198530#M65136</link>
      <description>&lt;P&gt;It's probably that the m. needs to be aprxMap. ?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 14:25:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198530#M65136</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-02T14:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate though folder and add lyrx to a map</title>
      <link>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198532#M65137</link>
      <description>&lt;P&gt;RuntimeError Traceback (most recent call last)&lt;BR /&gt;In [86]:&lt;BR /&gt;Line 3: aprxMap.addDataFromPath(os.path.join(arcpy.env.workspace, layer))&lt;/P&gt;&lt;P&gt;File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py, in addDataFromPath:&lt;BR /&gt;Line 1971: return convertArcObjectToPythonObject(self._arc_object.addDataFromPath(*gp_fixargs((data_path,), True)))&lt;/P&gt;&lt;P&gt;RuntimeError:&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 14:30:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198532#M65137</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-02T14:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate though folder and add lyrx to a map</title>
      <link>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198542#M65138</link>
      <description>&lt;P&gt;You are iterating through the list of layers, but, then you try to add the entire list instead of the layer(s):&lt;/P&gt;&lt;LI-CODE lang="c"&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")
aprxMap = aprx.listMaps("Map")[0]

arcpy.env.workspace = "Path to my data"

list_layers = arcpy.ListFiles("*.lyrx")

for layer in list_layers:
  m.addLayer(layer)
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does it work if you add the individual layers you are iterating through instead of&amp;nbsp;&lt;SPAN&gt;m.addLayer(list_layers)?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 14:36:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198542#M65138</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2022-08-02T14:36:48Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate though folder and add lyrx to a map</title>
      <link>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198545#M65139</link>
      <description>&lt;P&gt;ValueError Traceback (most recent call last)&lt;BR /&gt;In [89]:&lt;BR /&gt;Line 9: m.addLayer(layer)&lt;/P&gt;&lt;P&gt;File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\utils.py, in fn_:&lt;BR /&gt;Line 191: return fn(*args, **kw)&lt;/P&gt;&lt;P&gt;File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py, in addLayer:&lt;BR /&gt;Line 1843: return convertArcObjectToPythonObject(self._arc_object.addLayer(*gp_fixargs((add_layer_or_layerfile, add_position), True)))&lt;/P&gt;&lt;P&gt;ValueError: OS_AnnoPoint.lyrx&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 14:38:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198545#M65139</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-02T14:38:55Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate though folder and add lyrx to a map</title>
      <link>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198548#M65140</link>
      <description>&lt;P&gt;odd, because its essentially doing the same thing as your solution using glob. Without seeing the full code and we're now just looking at another way, I'd say keep using the glob version.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 14:40:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198548#M65140</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-02T14:40:48Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate though folder and add lyrx to a map</title>
      <link>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198551#M65141</link>
      <description>&lt;P&gt;It's not my really solution I found it on GIT hub and modified it slightly but it does work. Correct me if I'm wrong (probably!) but I think the difference is the glob solution iterates over the directory rather than creating a list first then iterating over that?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 14:47:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198551#M65141</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-02T14:47:02Z</dc:date>
    </item>
    <item>
      <title>Re: Iterate though folder and add lyrx to a map</title>
      <link>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198553#M65142</link>
      <description>&lt;P&gt;That is right in the concept. The glob.iglob (iterator glob) creates a generator/ yield object, so instead of populating a complete list first like the arcpy.ListFIles, it lets you iterate over a list without storing it.&lt;/P&gt;&lt;P&gt;Same principle, you are still iterating over a list but a difference is speed.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 14:57:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/iterate-though-folder-and-add-lyrx-to-a-map/m-p/1198553#M65142</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-02T14:57:26Z</dc:date>
    </item>
  </channel>
</rss>

