I create an empty file geodatabase (gdb), and I would like to import in this gdb several feature dataset, at least 120 different dataset. I would like to import those dataset from a table like an excel table.
I try to do this with the python command with something like :
arcpy.CreateFileGDB_management("C:/data/arcgis/gdb", "gdbTemp.gdb")
<Result 'C:/data/arcgis/gdb\\gdbTemp.gdb'>
>>> import arcpy
from arcpy import env
env.workspace = "C:/data/arcgis/gdb"
arcpy.CreateFeatureDataset_management("C:/data/arcgis/gdbTemp.gdb",
…
From the last line I don't know how to :
- import my spreadsheet
- tell I want for each line of the spreadsheet a new feature Dataset in my geodatabase
My actual spreadsheet looks like that, Its is very basic with only the name of the dataset (I want to go step by step).
So, I would like to create for each row a new dataset in the geodatabase.
I found something for an other post, It seems to be a good starting point :
fdList = [...]
Here I could make a command that get back from the spreadsheet the name of all my future dataset.
Then with a loop, add them on the geodatabase :
for fd in fdList:
arcpy.CreateFeatureDataset_management(""C:/data/arcgis/gdbTemp.gdb"", fd, "I:/python/MultipleFD2GDB/2229.prj")
I need to do this with the python command (is this arcpy?)
Best Answer
Below is the code you require:
You need to read the Excel file, I did this by converting it into a temporary dBase file which I delete at the end. The code then steps through the temporary table reading each row and using that as the name for the FeatureDataset. In my example I do not set a spatial reference.
I don't think (but could be wrong) that you can read an Excel table with a search cursor in
arcpy
. This answer to Reading Excel sheet in ArcPy script? discusses reading an Excel sheet using another Python module.