Hello,
I have successfully used the arcpy.SelectLayerByAttribute_management function, and sent the results to a shapefile using the following code:
arcpy.SelectLayerByAttribute_management(fc + "_new", 'NEW_SELECTION', SetQuery)
# Write the selected features to a new featureclass to the
# defined "out_path"
outfc = os.path.join(out_path, fc + "_Edited")
arcpy.CopyFeatures_management(fc + "_new", outfc)
What do I need to do if I want to send the results into a created personal or file database using the following code?
arcpy.management.CreateFileGDB(out_path, "NewForestGIS.gdb")
Thank You for your help
-Jeff
Solved! Go to Solution.
Hi Jeff,
I think it should just work as is if you replace the out_path in your "outfc" line with the path to the new geodatabase (including the name of the geodatabase NewForestGIS.gdb). I'm pretty sure CopyFeatures defaults to outputting as a shapefile if it's writing to a folder and a feature class if it's writing to a geodatabase.
Hi Jeff,
I think it should just work as is if you replace the out_path in your "outfc" line with the path to the new geodatabase (including the name of the geodatabase NewForestGIS.gdb). I'm pretty sure CopyFeatures defaults to outputting as a shapefile if it's writing to a folder and a feature class if it's writing to a geodatabase.
Hello Joshua,
Thank you so much for your reply with information how to create a featureclass in a personal or filedatabase. Using your suggestion, I did spend a couple of hours with the program last Thursday (I only work Mon-Thurs). I was not successful. Your solution must be correct, I just a need a little more time with the code and see why its not working. Once I get the code to work, I will update "accept as solution". Sorry for the delay.
-Jeff
Hi Jeff,
Feel free to post your code and what's going wrong and I can review it for you!
Cheers,
Josh
Hello Joshua, I tried a couple of times, and it still failed. On the third attempt, with your suggested change, it worked 😄 Hurray!
Thank You Joshua.
-Jeff
Hi Jeff,
Think you may have marked the wrong reply as the solution, but I'm glad to hear that it's all working for you now as you hoped 🙂 happy to help out!
Josh