Move SHP to gdb and ArcView license (newbie frustration)!!!

3146
54
04-11-2012 07:58 AM
LucaMoiana
New Contributor
Hi there,
What I need to do is move all the files into an mxd to a newly created gdb, chechking prj, and update mxd reference.

I have ArcGIS 10 SP4, license ArcView

I studied a bit of Python and get familiar with basic, then I copied some written code and pasted all together, attached is the code.

My frustration is that i can???t even move my shp files to a created gdb, is that because of my ArcView license?

PLEASE PLEASE PLEASE HELP

# Import system modules
import arcpy
from arcpy import env
import os
 
# Set environment settings
env.workspace = "C:/Users/a391665/Documents/AAAAPERSONALE/rugareto"

# Execute CreateFileGDB
arcpy.CreateFileGDB_management("C:/park", "test4")
 
# Set local variables
outWorkspace = "c:/park/test4.gdb"


# Use ListFeatureClasses to generate a list of shapefiles in the
#  workspace shown above.
fcList = arcpy.ListFeatureClasses()
 
# Execute CopyFeatures for each input shapefile
for shapefile in fcList:
    # Determine the new output feature class path and name
    outFeatureClass = os.path.join(outWorkspace, shapefile.strip(".shp"))
    arcpy.CopyFeatures_management(shapefile, outFeatureClass)
Tags (2)
0 Kudos
54 Replies
DarrenWiens2
MVP Honored Contributor
What does the error say (if any)? It shouldn't have anything to do with your licenses, both tools you use are available to ArcView.

edit: maybe try:
arcpy.CopyFeatures_management(shapefile, outWorkspace + os.sep + shapefile.rstrip(".shp"))
0 Kudos
LucaMoiana
New Contributor
Thank you!
here is the error I get when I run it on Python, even after your edit suggestion:

"Runtime error <class 'arcgisscripting.ExecuteError'>: Failed to execute. Parameters are not valid. ERROR 000732: Input Features: Dataset Percorsi.shp does not exist or is not supported Failed to execute (CopyFeatures). "

What does the error say (if any)? It shouldn't have anything to do with your licenses, both tools you use are available to ArcView.

edit: maybe try:
arcpy.CopyFeatures_management(shapefile, outWorkspace + os.sep + shapefile.rstrip(".shp"))
0 Kudos
ScottBlankenbeckler
Occasional Contributor
I would try changing the following section of code

# Set environment settings
env.workspace = "C:/Users/a391665/Documents/AAAAPERSONALE/rugareto"

# Execute CreateFileGDB
arcpy.CreateFileGDB_management("C:/park", "test4")

# Set local variables
outWorkspace = "c:/park/test4.gdb"




to

# Set environment settings
env.workspace = "C:\\Users\\a391665\\Documents\\AAAAPERSONALE\\rugareto"

# Execute CreateFileGDB
arcpy.CreateFileGDB_management("C:\\park", "test4")

# Set local variables
outWorkspace = "c:\\park\\test4.gdb"


0 Kudos
LucaMoiana
New Contributor
Thank you Scott I did it, here is the error on Python Window:

Runtime error <class 'arcgisscripting.ExecuteError'>: Failed to execute. Parameters are not valid. ERROR 000732: Input Features: Dataset Percorsi.shp does not exist or is not supported Failed to execute (CopyFeatures).

And here is what I get from PythonWin interactive window:

Traceback (most recent call last):
  File "C:\Python26\ArcGIS10.0\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 312, in RunScript
    exec codeObject in __main__.__dict__
  File "C:\Users\a391665\Desktop\Script2.py", line 10, in <module>
    arcpy.CreateFileGDB_management("C:\\park", "test4")
  File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\management.py", line 9453, in CreateFileGDB
    raise e
ExecuteError: ERROR 000258: Output C:\park\test4.gdb already exists
Failed to execute (CreateFileGDB).



I would try changing the following section of code

# Set environment settings
env.workspace = "C:/Users/a391665/Documents/AAAAPERSONALE/rugareto"

# Execute CreateFileGDB
arcpy.CreateFileGDB_management("C:/park", "test4")

# Set local variables
outWorkspace = "c:/park/test4.gdb"




to

# Set environment settings
env.workspace = "C:\\Users\\a391665\\Documents\\AAAAPERSONALE\\rugareto"

# Execute CreateFileGDB
arcpy.CreateFileGDB_management("C:\\park", "test4")

# Set local variables
outWorkspace = "c:\\park\\test4.gdb"


0 Kudos
ScottBlankenbeckler
Occasional Contributor

ExecuteError: ERROR 000258: Output C:\park\test4.gdb already exists
Failed to execute (CreateFileGDB).


Go to your C:\park directory and delete the test4.gdb and rerun the script
0 Kudos
DarrenWiens2
MVP Honored Contributor
Do you have a file called "Percorsi.shp"? In the folder "C:/Users/a391665/Documents/AAAAPERSONALE/rugareto"?

Also, after you import os, check if the gdb exists. If it does, delete it.
if os.path.exists("c:/park/test4.gdb"):
    arcpy.Delete_management("c:/park/test4.gdb")
0 Kudos
LucaMoiana
New Contributor
Sorry guys, I noticed.

Your help is so precious.
I wasn't able to add the "overwrite..." but I deleted the gdb and got it working from the PythonWin.
Although I have this error in the Python Win:
Runtime error <class 'arcgisscripting.ExecuteError'>: Failed to execute. Parameters are not valid. ERROR 000732: Input Features: Dataset Percorsi.shp does not exist or is not supported Failed to execute (CopyFeatures).
>>>


Do you have a file called "Percorsi.shp"? In the folder "C:/Users/a391665/Documents/AAAAPERSONALE/rugareto"?

Also, after you import os, check if the gdb exists. If it does, delete it.
if os.path.exists("c:/park/test4.gdb"):
    arcpy.Delete_management("c:/park/test4.gdb")
0 Kudos
MichaelVolz
Esteemed Contributor
Luca:

Can you add some print statements into your code to see that each step completes successfully?

eg: print("fcList completed successfully") after the line fcList = arcpy.ListFeatureClasses()

In addition, maybe print out the name of each featureclass in your fcList as there might be other data types in that folder such as a file geodatabase.

Darren's comment to check for the existence of the gdb would be helpful as you would need to delete the gdb each time as it gets created early on in your python script.
0 Kudos
LucaMoiana
New Contributor
I do have Percorsi.shp but it doesn't seem to work.


Sorry guys, I noticed.

Your help is so precious.
I wasn't able to add the "overwrite..." but I deleted the gdb and got it working from the PythonWin.
Although I have this error in the Python Win:
Runtime error <class 'arcgisscripting.ExecuteError'>: Failed to execute. Parameters are not valid. ERROR 000732: Input Features: Dataset Percorsi.shp does not exist or is not supported Failed to execute (CopyFeatures).
>>>
0 Kudos