def pasteRow(fc, query): dict = {} for row in arcpy.SearchCursor(fc,query): for x in [k.name for k in arcpy.ListFields(fc) if k.name not in ['OBJECTID','Shape']]: dict= row.getValue(x) irows = arcpy.InsertCursor(fc) row = irows.newRow() for x in dict: row.setValue(x,dict ) irows.insertRow(row)
pasteRow(fc,'"SITENAME"=\'PACIFIC AUTO SALVAGE\'')
>>> def cRows(xTimes): ... for i in range(0, xTimes): ... arcpy.CopyRows_management("tblMyRecords", "tblScratch") ... arcpy.Append_management("tblScratch","tblMyRecords") ...
>>> cRows(6)
Here's a way to automate Jan's workaround:
Open your table.
Open the python interpreter window
Type in this function>>> def cRows(xTimes): ... for i in range(0, xTimes): ... arcpy.CopyRows_management("tblMyRecords", "tblScratch") ... arcpy.Append_management("tblScratch","tblMyRecords") ...
Select a row or the rows you need to copy one or more times and call the function in the python window like this>>> cRows(6)
If you need X copies, give the function X - 1; you already have one copy in your table.
tblScratch should get written to your default gdb. If the function can't find it, try adding it to your layers.
It works inside and outside of an edit session.
def cRows(tblMyRecords, xTimes): arcpy.CopyRows_management(tblMyRecords, "in_memory/tblScratch") for i in range(0, xTimes): arcpy.Append_management("in_memory/tblScratch", tblMyRecords)
cRows("tblMyRecords", 1)
Hi Richard,
It's been a while since you posted your modified script. Where you able to solve any of your questions? Do you still use this script, or do you have a more polished version?