Select to view content in your preferred language

arcpy.da.instercursor adding blank rows.

09-07-2018 09:05 AM
New Contributor II

I am trying to copy a table from an oracle server to a filegdb table.  I can get the searchcursor to work and I can get the insercursor to add all the rows but the field values are all blank.  Any ideas?


field_names = [ for f in arcpy.ListFields(SourceTableFullPath)] 

edit = arcpy.da.Editor(targetPath)

cursor = arcpy.da.InsertCursor(TargetTablefullPath,field_names)

i = 0
for row in arcpy.da.SearchCursor(SourceTableFullPath, field_names, sourceFilterString):
   i = i + 1

   print row[0] + " " + row[1]
   if i > 10:
   print i

print "added rows?"

del row
del cursor

0 Kudos
3 Replies
MVP Honored Contributor

Since you're starting and immediately stopping an edit session, you may as well remove all that and see if it helps.

0 Kudos
New Contributor II

I didn't have any of that in to begin with.  I just started at creating the cursor but I still have the same problem.  I also tried doing it to a personal GDB.  All I can think of is that the new table gets an objectid field and somehow that is messing with the field count but even when I only call out two fields manually they still go in blank. 

0 Kudos
New Contributor II

I ended up creating a second copy of the table to insert into.  The first table is somehow read only. 

outTbl = str(arcpy.CreateTable_management(targetPath,targetTableName,SourceTableFullPath,"#").getOutput(0))

outTable2 = str(arcpy.TableToTable_conversion(outTbl,targetPath, targetTableName2 ).getOutput(0))