how to delete tables under a map using arcpy?

1216
5
Jump to solution
10-03-2020 03:18 AM
wwwu
by
New Contributor

I try to draw a real-time map based on one field. And I will update this field with another kept-on-generating dataframe. I forgo to finish it with updateCursor because it is so slow. Instead, I try to convert dbf into a csv file and merge it with that dataframe then convert it back to the dbf file.

It works well in 1st time. But since I have used the function TableToTable_conversion to generate a dbf file, it will add a table under that map in arcgis pro. Therefore I have to delete that table first before I run ableToTable_conversion to generate a generated dbf file. So what is the corresponding code in arcpy to delete that table?

BTW: I can visit these tables using this code:

tbs = mp.listTables()

for tb in tb:

   print(tb.name)

0 Kudos
1 Solution

Accepted Solutions
JoshuaBixby
MVP Esteemed Contributor

The tool you want to use is Delete (Data Management)—ArcGIS Pro | Documentation.  Although you can set the workspace and then just rely on names, be aware that if you have a table view and table with the exact same name, the table view will be deleted first and only leaving the table still on disk but not loaded in map.  Passing the full path of the table ensures the table will be deleted and table view removed from map.

View solution in original post

0 Kudos
5 Replies
JoshuaBixby
MVP Esteemed Contributor

The tool you want to use is Delete (Data Management)—ArcGIS Pro | Documentation.  Although you can set the workspace and then just rely on names, be aware that if you have a table view and table with the exact same name, the table view will be deleted first and only leaving the table still on disk but not loaded in map.  Passing the full path of the table ensures the table will be deleted and table view removed from map.

0 Kudos
wwwu
by
New Contributor

Thank you for your reply! I have known how to delete the table and substitute it with a new .dbf file. Now the problem is that I tried to use a for loop to keep updating the map displayed in the interface based on the newest updated data in each loop. But it seems that the map will update only once after the whole for loop is finished. I don't know why. Because in the arcgis Map, I can use refresh function to refresh it.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Without seeing more of your code, specifically the loop part, I can't really comment any further.

wwwu
by
New Contributor

I think I have solved this problem in another way with the function you provided under my other question!

Although the interface didn't update with the data, the exported Pictures has already been updated with mp.defaultView.exportToPNG.

Thank you! You saved my ass.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

I will go ahead and mark this question Assumed Answer, and you can mark the other question answered.

0 Kudos