Select to view content in your preferred language

How to communicate two lists

4114
7
Jump to solution
04-23-2015 04:03 PM
PierreWeisse
Deactivated User

Hello,

I'm having trouble with lists.

I work on two different workspaces

The first is a file geodatabase (a)

The second is an SDE geodatabase (b)

The aim is to remove the contents of feature classes contained in a list (b)

So far so good

Then copy the new records (a) in the entity classes of (b)

To delete the records I use arcpy.DeleteFeatures_management () function

To complete the feature classes with the new content I use the function

arcpy.CopyFeatures_management ()

Thank you for your help

0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Emeritus

so...how is it going?  Have you done this manually? Are you trying to produce a script from it?  Examine the Results Window to see the script syntax if so.  It will give you a starting point as to how to put this together.  Alternately, construct a model from modelbuilder which can be used itself and/or converted to a script.

View solution in original post

0 Kudos
7 Replies
DanPatterson_Retired
MVP Emeritus

so...how is it going?  Have you done this manually? Are you trying to produce a script from it?  Examine the Results Window to see the script syntax if so.  It will give you a starting point as to how to put this together.  Alternately, construct a model from modelbuilder which can be used itself and/or converted to a script.

0 Kudos
PierreWeisse
Deactivated User

Thank you very much for the quick reply.

Here is my script:

import arcpy, os

from arcpy import env

env.workspace ="M:\UTILISATEURS\Pierre\connexion SDE\srv-arcsde.recif.nc@sde_ore_adm.sde\SDE_ORE_ADM.TEST"

lst_destination = arcpy.ListFeatureClasses()

for fc in lst_destination:

    arcpy.DeleteFeatures_management(fc)

    print fc + " is delete"

So far, so good. This is the next step that I have a problem.

I can not seem to communicate this list with another list, to come to copy the new entities in the feature classes that have been deleted.

0 Kudos
DanPatterson_Retired
MVP Emeritus

​same procedure using Feature Class to Feature Class syntax as shown in the help topic.

I would, however, suggest that you copy the features from the source location first, prior to deleting them.  If the files are outside of a geodatabase, you can use pure python operating functions...but that is a different story.

PierreWeisse
Deactivated User

I can not use the tool "Feature Class To Feature Class (Conversion)"

That's why I use the tool arcpy.DeleteFeatures_management (). I work in an organization with many users who use data during updates.

This tool allows the updates even when users are connected to the base.

Process:

arcpy.DeleteFeatures_management ()

To clear the table for these records

arcpy.CopyFeatures_management ()

To fill the table with records last days

Thank you

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Are you working with versioned data?  The code snippet you provide will delete all of the features in the feature classes, so it appears you are completely purging the table and repopulating it from scratch.  If you are working with versioned data, this will make your add & delete tables grow substantially.  Do you really need to replace all the records or are you trying to synchronize subsets of records between the two data sources?  Deleting all the records in an SDE table when users are consuming data from the table seems like it would lead to some strange experiences for users.

PierreWeisse
Deactivated User

Hello Joshua and Dan,

These data are not versioned. These are data from one of our partners. They take care to versioning. Our organization recovers data via their FTP.

The data that we update, have a comparable table structure of an update to another. There may be new entities or additional information in the fields.

I use the functions:

arcpy.DeleteFeatures_management ()

To clear the table for these records

arcpy.CopyFeatures_management ()

To fill the table with records last days

Because the data can be used by other users when I wish performed the update. These same users are warned in advance that an update will take place. They are not surprised. A document is even sent them for their explained what those updates.

Thank you both

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

OK, got it.  You are caught up in Esri semantics.  The Copy Features tool won't work for you because it copies "features from the input feature class or layer to a new feature class."  Check out the Append tool.  Although it will work with multiple input datasets, it works just fine with one input dataset.