-1

i want to create a simple python script for create one file geodatabase but show me define error

# Import arcpy module


Import arcpy



import sys

import os

from arcpy import env

from arcpy.sa import *

# Local variables:

arcpy.CheckOutExtension("spatial")

arcpy.env.overwriteOutput = True

workspace = arcpy.GetParameterAsText(0)

arcpy.CreateFileGDB_management(workspace, file_gdb)

file_gdb = workspace + "file_gdb"
3
  • Would you be able to edit your Question to explain what you mean by "define error", please? – PolyGeo Mar 25 '14 at 10:10
  • Your file_gdb variable needs to be defined before creating the FGDB. – Aaron Mar 25 '14 at 12:59
  • es run now thanx guys,now if i want to import a feature class in file geodatabase that path is a right ? feature_class = workspace + file_gdb + "feature_class" – hellas Mar 25 '14 at 20:35
1

in the first line you should use import arcpy not Import arcpy . when you want to define workspace you should use arcpy.env.workspace.

import arcpy

import sys

import os

from arcpy import env

workspace = arcpy.GetParameterAsText(0)
arcpy.env.workspace = workspace
from arcpy.sa import *

# Local variables:

arcpy.CheckOutExtension("spatial")

arcpy.env.overwriteOutput = True



arcpy.CreateFileGDB_management(workspace, "file_gdb")
2
  • I agree with the little "i" for import but, in this instance, there is no need to use arcpy.env.workspace, because the workspace variable will work fine in the only place it is used (arcpy.CreateFileGDB_management). – PolyGeo Mar 25 '14 at 12:11
  • yes run now thanx guys,now if i want to import a feature class in file geodatabase that path is a right ? feature_class = workspace + file_gdb + "feature_class" – hellas Mar 25 '14 at 13:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.