Select to view content in your preferred language

Add table via python code

2839
3
08-01-2019 02:25 PM
ZavierWilliams
New Contributor

Does anyone know of code to add a table via python coding. I am creating a script to run within ArcMap that will create then add a table to the document?

0 Kudos
3 Replies
LanceCole
MVP Regular Contributor

Zavier,

You can add a table using the Create Table function in python from ArcGIS Desktop or Pro.

Create Table— ArcGIS Desktop 

Create Table—ArcGIS Pro 

Fields can be added to the table using Add Field function in python from Desktop or Pro

Add Field—ArcGIS Desktop 

Add Field—ArcGIS Pro

To add rows of data you can use an InsertCursor in python from Desktop or Pro

InsertCursor—ArcGIS Desktop 

InsertCursor—ArcGIS Pro

You can also add a table from other sources such as XLS, XLSX, CSV, TXT, DBF, etc. using Table to Table conversion from both Desktop and Pro

Table To Table—ArcGIS Desktop 

Table To Table—ArcGIS Pro

JoshuaBixby
MVP Esteemed Contributor

Lance Cole‌, your InsertCursor for ArcGIS Desktop is to the older/legacy cursors.  I suggest you send people to the DA cursors:  InsertCursor—Help | ArcGIS Desktop 

LanceCole
MVP Regular Contributor

Joshua, Thanks, missed that when I was searching and pasting the links last night.

0 Kudos