import sys, string, os, cx_Oracle, arcpy, datetime arcpy.env.workspace = "c:\\work\\scripting\\test\\testdata.gdb" arcpy.MakeFeatureLayer_management("rsids","rsid_view") rows = arcpy.SearchCursor("rsid_view","","","NUM; EXTENSION","NUM A") row = rows.next() while row: RSIDNum = str(row.getValue("NUM")) Ext = str(row.getValue("EXTENSION")) if Ext == "None": Ext = "" rsid = RSIDNum+Ext RSID = "RSID"+RSIDNum+Ext arcpy.CopyFeatures_management(RSID, "c:\\work\\scripting\\test\\testdata.gdb\\"+RSID) row - rows.next() del row del rows if arcpy.Exists("rsid_view"): arcpy.Delete_management("rsid_view") print "View deleted"
Joshua, I was wondering if you were still out there. I am having a problem with the above script again (I know 2 yrs later). The FeatureClassTo FeatureClass is not working. I get the dreaded ERROR 9999999. I can't figure out why. Some stuff has changed in the database that I would think make thing easier but I just can't seem to get it past that point. If you are available for a little bit I was hoping to ask for a little help, since you were the one that was so kind to helped me before. If you can help I will fill you in on what has changed in the database and what I thought would work. Thanks again.
Mike... I sent Josh a message, hopefully you will hear from him.
I really appreciate it. I hope it’s not much of a problem
Hello Mike,
I'm still kicking around. Feel free to ask away!
I'll see if I can help (and it looks like we may get help from guru Dan Patterson)
Again, thanks in advance for any help, and time. I hope this isn’t too hard to read. Basically, I am trying to do the same thing as before. I have a feature class (RSID)with a few hundred features. I would like to select each on and make it its own feature class and do stuff to it. So, I have everything done that I need to do to each RSID but I can’t seem to get the FeatureClassToFeatureClass to work. Now before, when we worked on it, there was a column NUM and an EXTENSION column that I needed and that is how we did what we did before. Now there is a NAME column that has what I need (both name and extension and when I dissolve on NAME I figure I don’t need a lot of what we had in there before. I thought that I could just search cursor through the NAME column, add “RSID” to the front of the name as I know that a feature class can’t start with a number (the NAME column looks like this ex. 789M, 801M, 541L) and make the name feature class. I am getting the ERROR 999999. I have what I did down below, and I have commented out the old code that we were using. To explain the script, I am making sure that that I have copies of feature classes and dissolving on NAME. I am than setting up some directories and feature datasets to put everything and making sure everything is correct with the slashes, than I do the searchcursor. It all works until it gets to the FeatureClassToFeatureClass. Any thoughts? I guess I haven't figured out how to copy and paste the script. The first attempt was pretty bad. The second was better but I decided just to attach it. Let me know if it doesn't work
Hello Mike, Thanks for the clear post.
Nice looking script, I have a few suggestions of the get-go.
arcpy.FeatureClassToFeatureClass_conversion(nfc, NewoutLocation, newFCName, "NAME = '"+row.NAME+"'")
arcpy.FeatureClassToFeatureClass_conversion(nfc, outLocation, newFCName, "NAME = '"+row.NAME+"'")
Let me know if those 2 changes do anything. Also,any chance you can post a small data set for testing?
Good luck!
Cool, that seemed to work. I was under the impression that the where clause was optional and that you didn’t have to have it as a parameter. This is working now. It is bombing at another point in the script where it is doing other things but is using FeatureClassToFeatureClass_conversion without a where clause. I will have to look into that a little more to determine the where clause that I am going to need. I just haven’t reached that point before now. Thanks again for the help. I am glad to know that my thinking was correct in that I didn’t need all that other code now, but it makes me wonder why I didn’t dissolve it in the first place. Oh well, live and learn. I will keep in mind the Dataset issue as well. I will let you know if something else comes up. Again, appreciate the help