AnsweredAssumed Answered

Validate if all items in list1 is in list of lists as sub list?

Question asked by Playa on Nov 23, 2016
Latest reply on Nov 24, 2016 by Dan_Patterson

I'm creating a list of feature class with lists of stats of each feature class to identify duplicate feature classes so that I can drop the rest and only copy one over to the a new directory. The items in the list that I'm using to identify uniqueness is file name; number of records in feature class; area (sqm) of minimum bounding# geometry. The file path with file name is also added but a sub list is returned for testing if the values exist within the final list of unique feature classes.

 

for each feature class:

append a list into an existing list made up of file path, file name, number records, area of minimum bounding geometry.

before adding the next feature class test whether the sub list [file name, number records, area minimum bounding geometry] don't already exist within the list of lists as a sublist (i.e. minus the file path) to prevent duplicate feature classes from being added to the list of lists of feature classes. I've tried using Python built in functions any and all with no luck. 

 

cont_list = []

for fc in focus:

  stats_list = [c:\folder1\fcs1, fcs1, 100, 200] 1

  stats_list = [c:\folder2\fcs1, fcs1, 100, 200] 2

  cont_list.append(stats_list)

  if stats_list[1:] in cont_list:

    print("exists")

  else:

    cont_list.append(stats_list)

 

note: all values in stats_list[1:] must match in list of list to be seen as a match to match duplicates. Any advice in how to achieve this will be appreciated.

Outcomes