By gis_user

2016-09-21 15:37:17 8 Comments

I am trying to append ~10,000 tables together using an ArcPy script.

I believe the method I am using does not work as the script is attempting to append too many tables at the same time. Would a possible work-around be a script that appends using looping?

import os
import sys
import string
import arcpy
from import *

WD = "C:/workspace"
arcpy.env.workspace = WD

#selects the 10,000 tables and tries to append them all together at the same time

arcpy.CreateTable_management(out_path=WD, out_name="append", template="C:/Workspace/template", config_keyword="")
tables1 = [table for table in arcpy.ListTables() if not table.startswith('append')]
arcpy.Append_management(inputs=tables1, target="ndvi_append", schema_type="TEST", field_mapping="", subtype="")


@Priscilla 2016-09-21 17:41:28

Here's a code sample to implement crmackey's suggestion above. 1)Open an insert cursor for your final location, 2) loop each table, 3) check if table doesn't start with append, 4) read table data with a search cursor, consumed in a list, 5) use insert cursor to push table data into final table.

insertCursor = arcpy.da.InsertCursor("ndvi_append", "*")
for table in arcpy.ListTables():
    if not table.startswith('append'):
        tableData = list(arcpy.da.SearchCursor(table, "*"))
        for data in tableData:

@fatih_dur 2016-09-22 00:22:28

The location of InsertCursor line seems incorrect!

@Priscilla 2016-09-22 15:15:27

Thanks @fatih_dur for your feedback. I updated my answer so that the insert cursor is only created once instead of every cycle of the loop.

@gis_user 2016-09-22 22:24:25

thank you! code ran perfectly. also worked when the cursor was created every cycle of the loop

@fatih_dur 2016-09-23 05:44:42

@user6665295, cursors are relatively expensive in terms of computational resources that you have. Obviously it is inserting a new row to the table whether you create once at the outset or numerous times with each loop, so practically working. But the current answer is logically correct. Also I suggest using with statement with arcpy.da cursors for a better efficacy.

Related Questions

Sponsored Content

2 Answered Questions

[SOLVED] Iteratively Updating Just Bottom Row in Table using ArcPy?

1 Answered Questions

[SOLVED] ArcPy Append GDB's

  • 2017-10-20 21:23:40
  • Dweber
  • 142 View
  • 0 Score
  • 1 Answer
  • Tags:   arcpy append

2 Answered Questions

[SOLVED] ArcPy Insert Cursor not inserting all rows?

  • 2012-05-01 13:55:02
  • Jason
  • 4779 View
  • 5 Score
  • 2 Answer
  • Tags:   arcpy cursor

1 Answered Questions

0 Answered Questions

Point Solar Radiation Computation using ArcPy?

1 Answered Questions

0 Answered Questions

Appending 10,000 tables using ArcPy fails to complete

  • 2016-09-28 16:10:21
  • gis_user
  • 82 View
  • 1 Score
  • 0 Answer
  • Tags:   arcpy arcgis-10.3

1 Answered Questions

[SOLVED] cannot get rid of sr.lock files while FOR LOOPING dbfTables

0 Answered Questions

Mass ArcPy GDB Load

1 Answered Questions

[SOLVED] Append, Insert or load Data into geodatabase table field

  • 2012-10-29 18:49:20
  • lemuel
  • 5227 View
  • 4 Score
  • 1 Answer
  • Tags:   arcpy

Sponsored Content