<?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: shapefiles fail to load into file geodatabase in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/shapefiles-fail-to-load-into-file-geodatabase/m-p/489084#M38260</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Not sure what's wrong with your code/machine, but there are many ways to skin a shapefile. Personally, I don't like using the env.workspace variable unless I have to (for example, if listing featureclasses in a FGDB). Also, I avoid using CAPS in file/folder names. This code "should" work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os, arcpy
rootDir = r"D:\pwwild\master"
fgdbName = "master.gdb"
fgdbPath = os.path.join(rootDir, fgdbName) 
arcpy.CreateFileGDB_management(rootDir, fgdbName)
shpList = ["cnddb.shp", "cnddbpnt.shp"] # I assume these are in rootDir
for shp in shpList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; inFC = os.path.join(rootDir, shp)
&amp;nbsp;&amp;nbsp;&amp;nbsp; outFC = os.path.join(fgdbPath, shp.split(".")[0])
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(inFC, outFC)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 21:31:20 GMT</pubDate>
    <dc:creator>ChrisSnyder</dc:creator>
    <dc:date>2021-12-11T21:31:20Z</dc:date>
    <item>
      <title>shapefiles fail to load into file geodatabase</title>
      <link>https://community.esri.com/t5/python-questions/shapefiles-fail-to-load-into-file-geodatabase/m-p/489083#M38259</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a python script that used to work.&amp;nbsp; It's pretty basic.&amp;nbsp; There are two shape files I want to load into an empty file geodatabase.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The path to the geodatabase is "D:\PWWILD\MASTER\" &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The name of the geodatabase is "MASTER.gdb"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The script actually creates the geodatabase prior to trying to load the shapefiles.&amp;nbsp; When I run the script "MASTER.gdb" is created.&amp;nbsp; When the script attempts to load the shape files they don't end up inside the geo db, a copy is made and ends up inside the folder "D:\PWWILD\"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Below is the script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# MakeGDB.py creates the geodatabase "MASTER.GDB"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Then shapefiles "cnddb.shp" &amp;amp; "cnddbpnt.shp" are loaded into&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# the newly created GDB.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcgisscripting&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp = arcgisscripting.create()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.workspace = "D:/PWWILD/MASTER"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.toolbox = "management"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.CreateFileGDB("D:/PWWILD/MASTER", "MASTER.gdb")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Put in error trapping in case an error occurs when running tool&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;try:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Set the workspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #gp.Workspace = "D:/PWWILD/M"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.FeatureClassToGeodatabase("cnddb.shp;cnddbpnt.shp", "D:/PWWILD/MASTER/MASTER.gdb")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;except:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # If an error occurred print the message to the screen&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print gp.GetMessages()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I guess I'm wondering what is going on.&amp;nbsp; The script ran fine yesterday on this machine and it still runs fine on an older XP machine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I ported the scripts from an XP machine which had ArcGIS 9.3.&amp;nbsp; Like I said they ran fine yesterday on the Win 7 machine.&amp;nbsp; Probably something I did, but I can't see it.&amp;nbsp; I changed the code thinking maybe because the newer machine runs 10.0 I should make sure it is compatible.&amp;nbsp; Here is that code.&amp;nbsp; It gives the same result.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# MakeGDB.py creates the geodatabase "MASTER.GDB"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# Then shapefiles "cnddb.shp" &amp;amp; "cnddbpnt.shp" are loaded into&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# the newly created GDB.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Import system modules&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.CreateFileGDB_management("D:/PWWILD/MASTER", "MASTER.gdb")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Set the workspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;env.workspace = "D:/PWWILD/MASTER"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Set local variables&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;inFeatures = ["cnddb.shp", "cnddbpnt.shp"]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;outLocation = "D:/PWWILD/MASTER/MASTER.gdb"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Execute TableToGeodatabase&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.FeatureClassToGeodatabase_conversion(inFeatures, outLocation)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;New script does the same thing, shapefiles end up in the "PWWILD" folder instead of the geo db.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hopefully someone has an explanation.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Glen&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jan 2013 23:59:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/shapefiles-fail-to-load-into-file-geodatabase/m-p/489083#M38259</guid>
      <dc:creator>GlenRouse</dc:creator>
      <dc:date>2013-01-10T23:59:43Z</dc:date>
    </item>
    <item>
      <title>Re: shapefiles fail to load into file geodatabase</title>
      <link>https://community.esri.com/t5/python-questions/shapefiles-fail-to-load-into-file-geodatabase/m-p/489084#M38260</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Not sure what's wrong with your code/machine, but there are many ways to skin a shapefile. Personally, I don't like using the env.workspace variable unless I have to (for example, if listing featureclasses in a FGDB). Also, I avoid using CAPS in file/folder names. This code "should" work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os, arcpy
rootDir = r"D:\pwwild\master"
fgdbName = "master.gdb"
fgdbPath = os.path.join(rootDir, fgdbName) 
arcpy.CreateFileGDB_management(rootDir, fgdbName)
shpList = ["cnddb.shp", "cnddbpnt.shp"] # I assume these are in rootDir
for shp in shpList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; inFC = os.path.join(rootDir, shp)
&amp;nbsp;&amp;nbsp;&amp;nbsp; outFC = os.path.join(fgdbPath, shp.split(".")[0])
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(inFC, outFC)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:31:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/shapefiles-fail-to-load-into-file-geodatabase/m-p/489084#M38260</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-11T21:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: shapefiles fail to load into file geodatabase</title>
      <link>https://community.esri.com/t5/python-questions/shapefiles-fail-to-load-into-file-geodatabase/m-p/489085#M38261</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I like the code Chris has provided.&amp;nbsp; As for the mystery why your code worked, then stopped, your rewrite looks fine except I'd stick with 'raw' strings.&amp;nbsp; May not fix your problem but try strings as in the following (also this convention was used by Chris) - make lower case if necessary:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;r"D:\PWWILD\MASTER"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If that doesn't work try creating the gdb at a different root location than your input shps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Jan 2013 05:25:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/shapefiles-fail-to-load-into-file-geodatabase/m-p/489085#M38261</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2013-01-11T05:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: shapefiles fail to load into file geodatabase</title>
      <link>https://community.esri.com/t5/python-questions/shapefiles-fail-to-load-into-file-geodatabase/m-p/489086#M38262</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks I will give these suggestions a try.&amp;nbsp; I appreciate the help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Jan 2013 13:19:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/shapefiles-fail-to-load-into-file-geodatabase/m-p/489086#M38262</guid>
      <dc:creator>GlenRouse</dc:creator>
      <dc:date>2013-01-11T13:19:54Z</dc:date>
    </item>
    <item>
      <title>Re: shapefiles fail to load into file geodatabase</title>
      <link>https://community.esri.com/t5/python-questions/shapefiles-fail-to-load-into-file-geodatabase/m-p/489087#M38263</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The code Chris provided worked.&amp;nbsp; I am going to adopt the lowercase strategy for file/folders names from here on out.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again Chris and Wayne for your help.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Jan 2013 13:30:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/shapefiles-fail-to-load-into-file-geodatabase/m-p/489087#M38263</guid>
      <dc:creator>GlenRouse</dc:creator>
      <dc:date>2013-01-11T13:30:37Z</dc:date>
    </item>
  </channel>
</rss>

