def insert_lines(line_fc, list_lines, fields_for_lines, is_del, writer): counter = 0 with arcpy.da.InsertCursor(line_fc, tuple(fields_for_lines)) as iCursor: for line in list_lines: corrected_company = cobb_common.extract_vendor(line[1][0][3], line[1][0][2]) array = arcpy.Array() array.add(arcpy.Point(line[0][0][0], line[0][0][1], line[0][0][2])) array.add(arcpy.Point(line[0][1][0], line[0][1][1], line[0][1][2])) row = (line[3], # Footage None, # OID corrected_company, # Vendor line[1][0][-3], # Facility Type 'Mummichog', # Algo version None, # Equipment line[1][0][5] if is_del else line[1][0][6], # Report Date line[1][0][7], # Job File Name line[1][0][8], # Job Order Number line[1][0][9], # Operator Name line[1][0][10], # Collection Type line[1][0][11], # Collection Date line[0][2], # Aban Indic arcpy.Polyline(array, None, True) ) iCursor.insertRow(row) writer.writerow((line[1][0][8], corrected_company, line[1][0][7], line[1][0][11], line[1][0][-3], line[3]) ) counter += 1 return counter
'GPS_ServiceLine_G_Point_Delivered', 'GPS_ChallengePoint_Delivered', 'GPS_CustomerConnection_G_Delivered', 'GPS_GasValve_Delivered', 'GPS_GasMain_Point_Approved', 'GPS_ServiceLine_G_Point_Approved', 'GPS_ChallengePoint_Approved', 'GPS_CustomerConnection_G_Approved', 'GPS_GasValve_Approved', ] states = ["OH", "PA", "VA"] fc_fields = ['VENDOR_FOLDER', 'GPS_OPERATORCOMPANY', 'WORKLOCATIONID'] where_clause = """"VENDOR_FOLDER" IS NOT NULL""" for current_state in states: print current_state dest_env_folder = 'E:/Richard/FileGBs/' # dest_env_db = "{}_Cobbler_{}.gdb".format(current_state, datetime.datetime.now().strftime("%m%d")) dest_env_db = "{}_Cobbler_0815.gdb".format(current_state) arcpy.env.workspace = dest_env_folder + dest_env_db for fc in point_fcs: with arcpy.da.UpdateCursor(fc, fc_fields, where_clause) as cursor: for row in cursor: corrected_company = cobb_common.extract_vendor(row[0], row[1]) row[2] = row[1] row[1] = corrected_company cursor.updateRow(row) print 'Done!'