import arcpy
from arcpy import env
arcpy.env.overwriteOutput = True
#set working MDB Here
arcpy.env.workspace = "C:/Users/atimpson/Desktop/Brunswick/PowerPlant.mdb/BPDMLayers"
dataList = arcpy.ListFeatureClasses()
mxd = arcpy.mapping.MapDocument("CURRENT")
lyrlist = arcpy.mapping.ListLayers(mxd)
# Reads a base table and outputs Feature Class and Layer Lists
readTable = open("C:/Users/atimpson/Desktop/ScriptTable/BPWorksLayers.csv")
# Figure out position of feature class and layer in the header
headerLine = readTable.readline()
valueList = headerLine.split(",")
fcPos = valueList.index("Feature Class")
lyrPos = valueList.index("Layers")
# Read lines in the file and append to comparison lists
baseFeature = []
baseLayer = []
for line in readTable.readlines():
segmentedLine = line.split(",")
baseFeature.append([segmentedLine[fcPos]])
baseLayer.append([segmentedLine[lyrPos]])
#Performs comparisons between project data/layers and idealized data/layers
if "BPWorks 2 Layers" in lyr.name:
for lyr, base in zip(lyrList, baseLayer):
if lyr != base:
print(lyr, "is different from", base)
mxd = arcpy.mapping.MapDocument("CURRENT")
readTable = open("C:/Users/atimpson/Desktop/ScriptTable/BPWorksLayers.csv", "r") # 'r' is for 'read only'for line in readTable.readlines():
segmentedLine = line.split(",")
baseFeature.append(segmentedLine[fcPos]) # I removed an extra bracket here
baseLayer.append(segmentedLine[lyrPos]) # and here
# I wrap this around all of my scripts, pretty much.
import traceback
import sys
try:
# all of your code here
except:
tbinfo = traceback.format_tb(sys.exc_info()[2])
print "Traceback Info:\n"
for item in tbinfo:
print item + "\n"
print "Error Info:\n{0}: {1}\n".format(sys.exc_type, sys.exc_value)
import csv
# Reads a base table and outputs Feature Class and Layer Lists
readTable = csv.reader(open("C:/Users/atimpson/Desktop/ScriptTable/BPWorksLayers.csv", "rb")
# Read the first line
first_line = readTable.next()
## comment out these two lines
#headerLine = readTable.readline()
#valueList = headerLine.split(",")
fcPos = first_line.index("Feature Class")
lyrPos = first_line.index("Layers")
# Read lines in the file and append to comparison lists
baseFeature = []
baseLayer = []
# now read second line and on ..
for line in readTable:
# make sure current line has as many items as the first line has
if len(line) >= len(first_line):
baseFeature.append(line[fcPos])
baseLayer.append(line[lyrPos])