# How to batch Check geometry in ArcGIS for a list of datasets from a CSV?

We have around 50+ gdb's(in different folders) which has 450 datasets in total. Among the 450, we have a list of 100 feature dataset's for which we have to do QAQC. So is it possible to batch Check geometry process ? From ArcGIS's help page I've come across this http://pro.arcgis.com/en/pro-app/tool-reference/data-management/check-geometry.htm This code works great for a single gdb to check geometry of all the datasets within that gdb. I would like to run Check geometry process only for particular datasets within particular gdb's.

Eg: D:\QAQC\f_c.csv This will have the list of datasets for which Check geometry process has to be run. CSV will have file path like

E:\Chk\A\ddd.gdb\Feature_dataset_1

E:\Chk\B\eee.gdb\Feature_dat_1

I know the file_path should not be represented like this. Just to throw some idea on what I want, I've mentioned the path like this

Edit:

This code worked like a charm

import csv
import arcpy

csvpath = r"path\to\csv"
with open(csvpath, "r") as csvfile:
fcs = [r[0] for r in csv.reader(csvfile)]
arcpy.CheckGeometry_management(fcs, "outtable")

• I think this question is pretty straight-forward at this point and should be reopened. It's really just about iterating a CSV, which is a very simple thing to do. – mr.adam Apr 22 '16 at 15:34

What you need is a way to read the CSV file with python, and for that you can use the csv module. So, very simply:

import csv
import arcpy

csv_path = r"path\to\csv"
with open(csv_path, "r") as csvfile:

# you can access columns in the row by using indices
# because the row is a list of its values

fcpath = row[0] # or whatever column
arcpy.CheckGeometry_management(fcpath, "outtable")


You could optionally make a list of all the feature class paths and pass that to a single Check Geometry function (instead of running the function once per feature class). I assume that the only main difference would be in the output table. You could use less lines to achieve this:

import csv
import arcpy

csv_path = r"path\to\csv"
with open(csv_path, "r") as csvfile:
fcs = [r[0] for r in csv.reader(csvfile)]

arcpy.CheckGeometry_management(fcs, "outtable")

• Thanks a lot. Worked great. Only thing is "csvpath" has to be changed csv_path while defining the path – joseph_k Apr 25 '16 at 9:30
• oops, good catch, sorry for the sloppiness. I'll fix that up. – mr.adam Apr 25 '16 at 14:01

Here is the following logic to iterate a csv and find related feature dataset (fd) within folders of gdbs:

1. Use arcpy.da.search cursor to iterate over .csv and get field fd path value
2. Create another function or nest os.walk method within step 1 and find all gdb within parent directory of directories
3. Create another function or nest (Once .gdb found) arcpy.da.walk to iterate over gdb to look for found fd name in step 2
4. Continue on with check geometry logic...
• i want only particular datasets to be checked. The name of the dataset's to be checked will be in a csv file with the path details (eg: D:\RD\aaa.gdb\Dataset_1) – joseph_k Apr 22 '16 at 12:20
• Your question needs re-worded, it seemed like you only needed help accessing many gdb within many directories, "This code wokrs great for a single gdb. I've no clue how to do it for n number of gdb's at a time." – artwork21 Apr 22 '16 at 13:52
• I've edited the question. – joseph_k Apr 22 '16 at 15:00