<?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: Create File GDB and store as variable in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/create-file-gdb-and-store-as-variable/m-p/224762#M17349</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just tried that. The script will run but the results don't have any records. Is there another way to create the GDB and store as a variable? Maybe I'm not understanding the whole .getOutput(0) thing. Sorry, it's been a while since I've done any python. I did some in college 4 years ago but never thought I would actually be using it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 Mar 2019 15:03:41 GMT</pubDate>
    <dc:creator>RyanF</dc:creator>
    <dc:date>2019-03-28T15:03:41Z</dc:date>
    <item>
      <title>Create File GDB and store as variable</title>
      <link>https://community.esri.com/t5/python-questions/create-file-gdb-and-store-as-variable/m-p/224760#M17347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm working on a script that originally had locations coded in but I want to make it where anyone in my office can use it and they can set their workspace up however they want. I've almost got it to work how I want. I think I have one more obstacle then I'm good.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have some parameters set up for user input.&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = arcpy.GetParameterAsText(0)&lt;/P&gt;&lt;P&gt;FileGDB_name = arcpy.GetParameterAsText(1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NewLocation = arcpy.CreateFileGDB_management(arcpy.env.workspace, FildGDB_Name)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;clipLayer = arcpy.Clip_analysis(RouteLayer, StateLayer, NewLocation + name + "Clip")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RouteLayer and StateLayer are additional parameters set up by the user. The script fails when it gets to the clip tool. I realize the way I have it set up, NewLocation calls the CreateFileGDB tool rather than the location of the GDB. I want to be able to create the GDB and store it as a variable so it can be used in other tools in the script. Could someone shed some light on how to do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Mar 2019 14:17:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-file-gdb-and-store-as-variable/m-p/224760#M17347</guid>
      <dc:creator>RyanF</dc:creator>
      <dc:date>2019-03-28T14:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: Create File GDB and store as variable</title>
      <link>https://community.esri.com/t5/python-questions/create-file-gdb-and-store-as-variable/m-p/224761#M17348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ArcGIS geoprocessing tools return &lt;A class="link-titled" href="https://pro.arcgis.com/en/pro-app/arcpy/classes/result.htm" title="https://pro.arcgis.com/en/pro-app/arcpy/classes/result.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Result—ArcPy classes | ArcGIS Desktop&lt;/A&gt;&amp;nbsp; objects.&amp;nbsp; You can't append a string to a result object the way you are trying in your code.&amp;nbsp; Try changing the NewLocation line to:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;NewLocation &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CreateFileGDB_management&lt;SPAN class="punctuation 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;workspace&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; FildGDB_Name&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;getOutput&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:56:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-file-gdb-and-store-as-variable/m-p/224761#M17348</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-11T10:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: Create File GDB and store as variable</title>
      <link>https://community.esri.com/t5/python-questions/create-file-gdb-and-store-as-variable/m-p/224762#M17349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just tried that. The script will run but the results don't have any records. Is there another way to create the GDB and store as a variable? Maybe I'm not understanding the whole .getOutput(0) thing. Sorry, it's been a while since I've done any python. I did some in college 4 years ago but never thought I would actually be using it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Mar 2019 15:03:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-file-gdb-and-store-as-variable/m-p/224762#M17349</guid>
      <dc:creator>RyanF</dc:creator>
      <dc:date>2019-03-28T15:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: Create File GDB and store as variable</title>
      <link>https://community.esri.com/t5/python-questions/create-file-gdb-and-store-as-variable/m-p/224763#M17350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think it's the way you worded the output, try this for your next line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="language-python line-numbers"&gt;&lt;CODE&gt;clipLayer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Clip_analysis&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;RouteLayer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; StateLayer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; NewLocation &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"/Clip"&lt;/SPAN&gt;&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want it as a variable.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="line-numbers language-csharp"&gt;&lt;CODE&gt;GDBvar &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;workspace &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"\\"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; FileGDB_name&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Mar 2019 15:11:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-file-gdb-and-store-as-variable/m-p/224763#M17350</guid>
      <dc:creator>MatthewDriscoll</dc:creator>
      <dc:date>2019-03-28T15:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: Create File GDB and store as variable</title>
      <link>https://community.esri.com/t5/python-questions/create-file-gdb-and-store-as-variable/m-p/224764#M17351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That still gives me a result with no records.&lt;/P&gt;&lt;P&gt;I want to keep the name variable in there. That is holding the name of the state for each clip layer (i.e. name = "Texas"). For example, an output would be something like .......New.gdb\TexasClip which is why I thought NewLocation + name + "Clip" would work.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Mar 2019 15:32:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-file-gdb-and-store-as-variable/m-p/224764#M17351</guid>
      <dc:creator>RyanF</dc:creator>
      <dc:date>2019-03-28T15:32:26Z</dc:date>
    </item>
    <item>
      <title>Re: Create File GDB and store as variable</title>
      <link>https://community.esri.com/t5/python-questions/create-file-gdb-and-store-as-variable/m-p/224765#M17352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So it creates the feature but the feature is empty?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Mar 2019 15:43:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-file-gdb-and-store-as-variable/m-p/224765#M17352</guid>
      <dc:creator>MatthewDriscoll</dc:creator>
      <dc:date>2019-03-28T15:43:26Z</dc:date>
    </item>
    <item>
      <title>Re: Create File GDB and store as variable</title>
      <link>https://community.esri.com/t5/python-questions/create-file-gdb-and-store-as-variable/m-p/224766#M17353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Correct, it creates the feature but it's empty.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Mar 2019 16:07:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-file-gdb-and-store-as-variable/m-p/224766#M17353</guid>
      <dc:creator>RyanF</dc:creator>
      <dc:date>2019-03-28T16:07:48Z</dc:date>
    </item>
    <item>
      <title>Re: Create File GDB and store as variable</title>
      <link>https://community.esri.com/t5/python-questions/create-file-gdb-and-store-as-variable/m-p/224767#M17354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So here's the code I have. I just ran like this. It'll create the GDB but the result of the clip tool gets stored at the workspace level rather than being stored in the GDB. I must have been using some bad data earlier which may have been causing the output to have no records. The output now has records. However, I want a feature class stored inside the GDB rather than a shapefile.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;arcpy.env.workspace = arcpy.GetParameterAsText(0)
RouteLayer = arcpy.GetParameterAsText(1)
StateLayer = arcpy.GetParameterAsText(2)
StateTaxDistricts = arcpy.GetParameterAsText(3)
FileGDB_Name = arcpy.GetParameterAsText(4)

GDB = arcpy.CreateFileGDB_management(arcpy.env.workspace, FileGDB_Name).getOutput(0)

stateName = os.path.basename(StateLayer).rstrip(os.path.splitext(StateLayer)[0])
name = stateName[:-1]

clipLayer = arcpy.Clip_analysis(RouteLayer, StateLayer, GDB + name + "_Clip")&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;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:56:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-file-gdb-and-store-as-variable/m-p/224767#M17354</guid>
      <dc:creator>RyanF</dc:creator>
      <dc:date>2021-12-11T10:56:52Z</dc:date>
    </item>
    <item>
      <title>Re: Create File GDB and store as variable</title>
      <link>https://community.esri.com/t5/python-questions/create-file-gdb-and-store-as-variable/m-p/224768#M17355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="language-none" style="color: #000000; background: #f5f2f0; border: 0px; margin: 0.5em 0px; padding: 1em 1em 1em 3.8em;"&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;clipLayer = arcpy.Clip_analysis(RouteLayer, StateLayer, GDB + "\\" + name + "_Clip")&lt;SPAN class="line-numbers-rows"&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;You need the \ in the path.&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Mar 2019 17:37:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-file-gdb-and-store-as-variable/m-p/224768#M17355</guid>
      <dc:creator>MatthewDriscoll</dc:creator>
      <dc:date>2019-03-28T17:37:37Z</dc:date>
    </item>
    <item>
      <title>Re: Create File GDB and store as variable</title>
      <link>https://community.esri.com/t5/python-questions/create-file-gdb-and-store-as-variable/m-p/224769#M17356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ha! I forgot something so simple! My script now works the way I want it to! Thanks for the help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Mar 2019 17:44:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-file-gdb-and-store-as-variable/m-p/224769#M17356</guid>
      <dc:creator>RyanF</dc:creator>
      <dc:date>2019-03-28T17:44:37Z</dc:date>
    </item>
    <item>
      <title>Re: Create File GDB and store as variable</title>
      <link>https://community.esri.com/t5/python-questions/create-file-gdb-and-store-as-variable/m-p/224770#M17357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please mark someone's answer correct to close out the question.&amp;nbsp; Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Mar 2019 19:33:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/create-file-gdb-and-store-as-variable/m-p/224770#M17357</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-03-28T19:33:17Z</dc:date>
    </item>
  </channel>
</rss>

