<?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: Scratch GDB being treated as folder instead of FGDB in script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/scratch-gdb-being-treated-as-folder-instead-of/m-p/1554526#M73131</link>
    <description>&lt;P&gt;I have my scripts automatically delete the scratch GDB (if it exists) at the beginning of the script, like so:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;if arcpy.Exists(arcpy.env.scratchGDB): arcpy.Delete_management(arcpy.env.scratchGDB)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;calling arcpy.env.scratchGDB will automatically create it if it doesn't exist, so this snippet ensures that it's created fresh. If it "becomes" a folder, it will delete the folder version and replace it the an empty GDB version.&lt;/P&gt;&lt;P&gt;Notably, this will not create problems for publishing as&amp;nbsp; GP service.&lt;/P&gt;</description>
    <pubDate>Thu, 31 Oct 2024 21:27:12 GMT</pubDate>
    <dc:creator>DarrenConly</dc:creator>
    <dc:date>2024-10-31T21:27:12Z</dc:date>
    <item>
      <title>Scratch GDB being treated as folder instead of FGDB in script</title>
      <link>https://community.esri.com/t5/python-questions/scratch-gdb-being-treated-as-folder-instead-of/m-p/72808#M5972</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am writing output data to the scratch geodatabase in a script - it was working great before but now it is no longer working and I'm trying to figure out if it's an IDE problem or something else. When I write data to the scratch geodatabase, it is treating it as a folder and appending ".shp" to the end of the output data instead of treating it as a file geodatabase and writing the output data as a feature class like it's supposed to. Additionally, it will run through the first tool call and write the output, but then the second tool call results in an error because it's trying to append ".shp.shp" to the output data name which is obviously invalid... I'm leaning towards this being an IDE problem because the script works great if I add the toolbox to ArcMap and run it inside there. Has anybody else seen this fishy behavior using PyCharm?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem script:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;scratchGDB &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;scratchGDB

&lt;SPAN class="comment token"&gt;#First tool call appends .shp to singlepart&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;#output looks like this: C:\Users\xxx\AppData\Local\Temp\scratch.gdb\singlepart.shp&lt;/SPAN&gt;
svyPtFC &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MultipartToSinglepart_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;multipartFL&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;join&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;scratchGDB&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'singlepart'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;#Second tool call tries to append .shp.shp to FinalOutput&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;#Error says: ExecuteError: ERROR 000210: Cannot create output &lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;#C:\Users\xxx\AppData\Local\Temp\scratch.gdb\FinalOutput.shp.shp&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;#ERROR 000354: The name contains invalid characters&lt;/SPAN&gt;
filename &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;join&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;scratchGDB&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"FinalOutput"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
svyPtFC &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Eliminate_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;sliverFL&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; filename&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It truly does write the shapefile out into the geodatabase folder:&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="410320" alt="" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/410320_Capture.JPG" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I run this code to check if it's a geodatabase I get this:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;scratchGDB &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;scratchGDB

desc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Describe&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;scratchGDB&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; desc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;workspaceType

&lt;SPAN class="comment token"&gt;#Prints "FileSystem"‍‍‍‍‍‍&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How do I get it to be seen as a file geodatabase when running in an IDE?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:49:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/scratch-gdb-being-treated-as-folder-instead-of/m-p/72808#M5972</guid>
      <dc:creator>MKF62</dc:creator>
      <dc:date>2021-12-10T22:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: Scratch GDB being treated as folder instead of FGDB in script</title>
      <link>https://community.esri.com/t5/python-questions/scratch-gdb-being-treated-as-folder-instead-of/m-p/72809#M5973</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well I fixed it. I had to set the scratchWorkspace first. No idea why it was working before without setting that, but it no longer likes to have the scratch.gdb sitting in AppData\Local\Temp.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kinda stinks that I have to do this though because I'll need to remember to comment the scratchWorkspace line out when I publish it as a&amp;nbsp;geoprocessing service since the&amp;nbsp;GP service should use the jobs folder as it's workspace, thus the directory of the scratchWorkspace will never be the same and should not be set.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Fixed code:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;scratchWorkspace &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;'C:\Users\xxx\Desktop\GIS_Testing'&lt;/SPAN&gt;
scratchGDB &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;scratchGDB

&lt;SPAN class="comment token"&gt;#scratchGDB now resides at C:\Users\xxx\Desktop\GIS_Testing\scratch.gdb‍‍‍‍&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:49:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/scratch-gdb-being-treated-as-folder-instead-of/m-p/72809#M5973</guid>
      <dc:creator>MKF62</dc:creator>
      <dc:date>2021-12-10T22:49:38Z</dc:date>
    </item>
    <item>
      <title>Re: Scratch GDB being treated as folder instead of FGDB in script</title>
      <link>https://community.esri.com/t5/python-questions/scratch-gdb-being-treated-as-folder-instead-of/m-p/1554526#M73131</link>
      <description>&lt;P&gt;I have my scripts automatically delete the scratch GDB (if it exists) at the beginning of the script, like so:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;if arcpy.Exists(arcpy.env.scratchGDB): arcpy.Delete_management(arcpy.env.scratchGDB)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;calling arcpy.env.scratchGDB will automatically create it if it doesn't exist, so this snippet ensures that it's created fresh. If it "becomes" a folder, it will delete the folder version and replace it the an empty GDB version.&lt;/P&gt;&lt;P&gt;Notably, this will not create problems for publishing as&amp;nbsp; GP service.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2024 21:27:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/scratch-gdb-being-treated-as-folder-instead-of/m-p/1554526#M73131</guid>
      <dc:creator>DarrenConly</dc:creator>
      <dc:date>2024-10-31T21:27:12Z</dc:date>
    </item>
  </channel>
</rss>

