I am having some difficulty conceptualizing how the code should work for a custom ArcPy Script tool. Currently our work flow involves QA/QC and taking a csv file and joining it to a feature class. From there we calculate each field individually based on the values in the csv. This takes a tremendous amount of time. I am trying to automate this with a script. I am looking to create a tool allows one input (the csv file) and the tool will read the csv, join it to the feature class and then populates the fields automatically. I would also like to have some errors thrown if there is not able to join/calculate etc. I am not sure how this should flow.
import arcpy
import csv
def bringincsv(csv):
with open(arcpy.GetParameterAsText(0), "rb") as csv:
reader = csv.reader(csv, delimiter=",")
next(reader):
for row in reader:
facilityid = str(row[0])
diameter = double(row[1])
hyperlink_cctv = string(row[2])
hyperlink_rpt = string(row[3])
try:
arcpy.env.workspace = 'CURRENT'
inspection = arcpy.GetParameterAsText(0)
arcpy.MakeTableView_management(in_table=inspection, out_view= 'Inspection')
arcpy.AddJoin_management('Memphis.GIS.ssGravityMain', 'FACILITYID',
'Inspection', facilityid, 'KEEP_COMMON')
arcpy.CalculateField_management('Memphis.GIS.ssGravityMain', diameter, ##The
csv files diameter)
arcpy.CalculateField_management('Memphis.GIS.ssGravityMain', hyperlink_cctv,
##The csv files values)
arcpy.CalculateField_management('Memphis.GIS.ssGravityMain', hyperlink_rpt,
##The csv files values)