How to work with geodatabases?

4458
12
03-04-2015 06:38 AM
SaidAkif
New Contributor III

Hi all

In my python code scripting, some time I used some function to do analysis on shapefile. Those function need to specify the .shp in the filename like arcpy.Rename_management(output+'.shp', filename). When I used files in geodatabase, my script crashed.

I am wondering how I can handle this problem?

I want just specify that my script loop over lot of files.

Thanks in advance

0 Kudos
12 Replies
TedKowal
Occasional Contributor III

It is hard to tell from your description what your problem is?  If you would attach some sample code where you are having the problem; someone would be able to assist you better.

0 Kudos
SaidAkif
New Contributor III

Here is a peace of my code:

Capture1.PNG

0 Kudos
OwainCatton
New Contributor III

Hi Said,

If you want to use the script for both Shapefiles and Geodatabases, you will need to check the input dataset for which data type it is. As at the moment you are appending ".shp" to the name which is invalid for the Geodatabases.

You can access which data type is input via the Describe function as seen here http://resources.arcgis.com/en/help/main/10.2/index.html#//018v0000002v000000

Hope  that helps,

Owain

0 Kudos
BlakeTerhune
MVP Regular Contributor

Your link is doubled up. I think you meant to go to ArcGIS Help 10.2 - Workspace properties (arcpy)

0 Kudos
SaidAkif
New Contributor III

Sorry. I did not find the editor title bar (or advanced editor link)

0 Kudos
BlakeTerhune
MVP Regular Contributor

Thanks for posting your code, but a screenshot is not very helpful if someone wants to copy it. Please post again as text with Python syntax highlighting.

Posting Code blocks in the new GeoNet

0 Kudos
SaidAkif
New Contributor III

this what I haveCapture3.PNG

0 Kudos
BlakeTerhune
MVP Regular Contributor

There should be a "Use advanced editor" link in the upper right corner of the reply box. What browser are you using?

Re: How to format a code sample on GeoNet?

0 Kudos
SaidAkif
New Contributor III


I use IE

0 Kudos