<?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: Using a list with arcpy.env.workspace in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/using-a-list-with-arcpy-env-workspace/m-p/1380473#M69825</link>
    <description>&lt;P&gt;Yep, it's there. I took out the copy-the-geodatabase part (which works just fine) to narrow down the issue and save time while I run this over and over (and over...)&lt;/P&gt;</description>
    <pubDate>Fri, 09 Feb 2024 17:25:07 GMT</pubDate>
    <dc:creator>TychoGranville</dc:creator>
    <dc:date>2024-02-09T17:25:07Z</dc:date>
    <item>
      <title>Using a list with arcpy.env.workspace</title>
      <link>https://community.esri.com/t5/python-questions/using-a-list-with-arcpy-env-workspace/m-p/1380062#M69819</link>
      <description>&lt;P&gt;I am trying to copy a geodb to a different name, do work on the copy, then overwrite the original. My error checking fails before it can even start.&lt;/P&gt;&lt;P&gt;My error checking is to make sure the projection is correct before continuing on that (copied) FC. What I'm running into is changing&amp;nbsp;arcpy.env.workspace "on the fly" to the newly created geodb; it can't find the FC's to check the projection.&lt;/P&gt;&lt;P&gt;I've narrowed the snippet below to just show the error generated (and only one list item), not the work I'm trying to do. I have tried all manner of things trying to put a string together for the "on the fly" part.&lt;/P&gt;&lt;P&gt;Python 2 because that's all they have.&lt;/P&gt;&lt;LI-SPOILER&gt;&lt;LI-CODE lang="c"&gt;import arcpy
### Lists
geodb_list = [r"S:\GIS\Scratch\Conversion2\GISPWBASE.gdb"]
# Note that 2nd file exists: "S:\GIS\Scratch\Conversion2\GISPWBASE.gdbsp.gdb"

for geodb in geodb_list:
 env = str(geodb)
 ext = "sp.gdb"
 geodb2 = str(env+ext)
 arcpy.env.workspace = env
 feature_classes = arcpy.ListFeatureClasses()
 print feature_classes
 for fc in feature_classes:
  spatial_ref = arcpy.Describe(fc).spatialReference
  print (spatial_ref.name)
 #
 arcpy.env.workspace = geodb2
 feature_classes = arcpy.ListFeatureClasses()
 print feature_classes
 for fc in feature_classes:
  spatial_ref = arcpy.Describe(fc).spatialReference
  print (spatial_ref.name)
  
  #OUTPUT
  [u'Locates', u'Easements', u'NWGASMAPS', u'NWNaturalGas', u'namedstreams', u'lakes_rivers', u'LocatesAnno', u'addresses', u'Taxlots', u'Roads', u'TheDallesIrrigation']
NAD_1927_StatePlane_Oregon_North_FIPS_3601
NAD_1927_StatePlane_Oregon_North_FIPS_3601
NAD_1927_StatePlane_Oregon_North_FIPS_3601
NAD_1927_StatePlane_Oregon_North_FIPS_3601
NAD_1927_StatePlane_Oregon_North_FIPS_3601
NAD_1927_StatePlane_Oregon_North_FIPS_3601
NAD_1927_StatePlane_Oregon_North_FIPS_3601
NAD_1927_StatePlane_Oregon_North_FIPS_3601
NAD_1927_StatePlane_Oregon_North_FIPS_3601
NAD_1927_StatePlane_Oregon_North_FIPS_3601
NAD_1927_StatePlane_Oregon_North_FIPS_3601
[u'Locates', u'Easements', u'NWGASMAPS', u'NWNaturalGas', u'namedstreams', u'lakes_rivers', u'LocatesAnno', u'addresses', u'Taxlots', u'Roads', u'TheDallesIrrigation']
Traceback (most recent call last):
  File "&amp;lt;module1&amp;gt;", line 37, in &amp;lt;module&amp;gt;
  File "C:\Program Files (x86)\ArcGIS\Desktop10.7\arcpy\arcpy\__init__.py", line 1260, in Describe
    return gp.describe(value, data_type)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.7\arcpy\arcpy\geoprocessing\_base.py", line 376, in describe
    self._gp.Describe(*gp_fixargs(args, True)))
IOError: "Locates" does not exist&lt;/LI-CODE&gt;&lt;/LI-SPOILER&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Tycho&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2024 22:06:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-list-with-arcpy-env-workspace/m-p/1380062#M69819</guid>
      <dc:creator>TychoGranville</dc:creator>
      <dc:date>2024-02-08T22:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: Using a list with arcpy.env.workspace</title>
      <link>https://community.esri.com/t5/python-questions/using-a-list-with-arcpy-env-workspace/m-p/1380330#M69822</link>
      <description>&lt;P&gt;Does it work if you just join the path of the featureclass to geodb?&lt;/P&gt;&lt;LI-CODE lang="python"&gt; for fc in feature_classes:
  spatial_ref = arcpy.Describe(os.path.join(geodb,fc)).spatialReference
  print (spatial_ref.name)&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 09 Feb 2024 15:11:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-list-with-arcpy-env-workspace/m-p/1380330#M69822</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2024-02-09T15:11:24Z</dc:date>
    </item>
    <item>
      <title>Re: Using a list with arcpy.env.workspace</title>
      <link>https://community.esri.com/t5/python-questions/using-a-list-with-arcpy-env-workspace/m-p/1380448#M69823</link>
      <description>&lt;P&gt;Unfortunately that adds a / to the path and still gives me pretty much the same error&amp;nbsp;("cannot find"&amp;nbsp;vs "does not exist"):&lt;/P&gt;&lt;P&gt;&lt;EM&gt;for fc in feature_classes:&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;spatial_ref = arcpy.Describe(os.path.join(geodb2,fc)).spatialReference&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;print (spatial_ref.name)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;IOError: "S:\GIS\Scratch\Conversion2\GISPWBASE.gdbsp.gdb\Locates" does not exist&lt;/P&gt;&lt;P&gt;(I need to use &lt;EM&gt;geodb2&lt;/EM&gt; as that is the variable that is failing)&lt;BR /&gt;&lt;BR /&gt;Part of what I don't understand is both versions of the&amp;nbsp;&lt;EM&gt;arcpy.env.workspace&lt;/EM&gt; can find the feature classes with the same printed output:&lt;/P&gt;&lt;PRE&gt; [u'Locates', u'Easements', u'NWGASMAPS', u'NWNaturalGas', u'namedstreams', u'lakes_rivers', u'LocatesAnno', u'addresses', u'Taxlots', u'Roads', u'TheDallesIrrigation']&lt;/PRE&gt;&lt;P&gt;but the hacked together one can't find the FCs for the next step.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2024 17:15:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-list-with-arcpy-env-workspace/m-p/1380448#M69823</guid>
      <dc:creator>TychoGranville</dc:creator>
      <dc:date>2024-02-09T17:15:12Z</dc:date>
    </item>
    <item>
      <title>Re: Using a list with arcpy.env.workspace</title>
      <link>https://community.esri.com/t5/python-questions/using-a-list-with-arcpy-env-workspace/m-p/1380454#M69824</link>
      <description>&lt;P&gt;Another dumb question but I have to ask: does geodb2 actually exist?&lt;/P&gt;&lt;P&gt;Right now it looks like you're naming it but not creating it.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2024 17:18:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-list-with-arcpy-env-workspace/m-p/1380454#M69824</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2024-02-09T17:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: Using a list with arcpy.env.workspace</title>
      <link>https://community.esri.com/t5/python-questions/using-a-list-with-arcpy-env-workspace/m-p/1380473#M69825</link>
      <description>&lt;P&gt;Yep, it's there. I took out the copy-the-geodatabase part (which works just fine) to narrow down the issue and save time while I run this over and over (and over...)&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2024 17:25:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-list-with-arcpy-env-workspace/m-p/1380473#M69825</guid>
      <dc:creator>TychoGranville</dc:creator>
      <dc:date>2024-02-09T17:25:07Z</dc:date>
    </item>
    <item>
      <title>Re: Using a list with arcpy.env.workspace</title>
      <link>https://community.esri.com/t5/python-questions/using-a-list-with-arcpy-env-workspace/m-p/1380507#M69826</link>
      <description>&lt;P&gt;What if you used an underscore instead of . for your 2nd geodatabase? like:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;geodb2 = env.replace('.', '_') + ext&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 09 Feb 2024 17:52:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-list-with-arcpy-env-workspace/m-p/1380507#M69826</guid>
      <dc:creator>JeffWard</dc:creator>
      <dc:date>2024-02-09T17:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: Using a list with arcpy.env.workspace</title>
      <link>https://community.esri.com/t5/python-questions/using-a-list-with-arcpy-env-workspace/m-p/1380525#M69827</link>
      <description>&lt;P&gt;WOOT! It worked!! I've been banging my head on this for an embarrassing amount of time.&lt;/P&gt;&lt;P&gt;I'm so used to seeing files that have extra dots in the name before the extension this would never have occurred to me. Need to revert back to the old DOS days of only a dot before the the extension, no special characters, no spaces. Not sure I can manage 8 character names though...&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2024 18:28:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-list-with-arcpy-env-workspace/m-p/1380525#M69827</guid>
      <dc:creator>TychoGranville</dc:creator>
      <dc:date>2024-02-09T18:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using a list with arcpy.env.workspace</title>
      <link>https://community.esri.com/t5/python-questions/using-a-list-with-arcpy-env-workspace/m-p/1381086#M69849</link>
      <description>&lt;P&gt;I'm glad it worked for you. I run in fear from spaces in file names and folder names. I am mocked by my younger colleagues. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Feb 2024 15:49:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-list-with-arcpy-env-workspace/m-p/1381086#M69849</guid>
      <dc:creator>JeffWard</dc:creator>
      <dc:date>2024-02-12T15:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: Using a list with arcpy.env.workspace</title>
      <link>https://community.esri.com/t5/python-questions/using-a-list-with-arcpy-env-workspace/m-p/1381088#M69850</link>
      <description>&lt;P&gt;The weird thing is I manually made a file gdb that looked just like his and it worked just fine in the python window?&lt;/P&gt;&lt;P&gt;example.gdbsp.gdb&lt;/P&gt;&lt;P&gt;Unless this is only an issue in Python 2.7?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Feb 2024 15:52:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-list-with-arcpy-env-workspace/m-p/1381088#M69850</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2024-02-12T15:52:15Z</dc:date>
    </item>
  </channel>
</rss>

