Hi i am trying to export some values from a number of shapefiles to a text file so as to use it to creat a point shapefile. The process is succeded ONLY when i put my files in the table of context. Why is that? **I have only folders no GDBase or .mxd**
In addition there is A problem with my code cause i can't get the right calculation of AVGDISTANCES i put it outside if and for, but nothing changed. FOR EXAMPLE for DISTANCE = 170, 170, 160, 150 i should get AVGDISTANCES= 162.5 not 150. This is my code:
import arcpy import os from arcpy import env Routesworkspace = arcpy.GetParameterAsText(2) env.workspace = Routesworkspace cases = ['RCs4s3s2c10_S', 'RCs4s3s2c20_S', 'RCs4s3s2c30_S', 'RCs4s3s2c40_S'] for fc in arcpy.ListFeatureClasses(): for case in cases: if fc.startswith(case): fields = ['DISTANCE', 'DURATION'] SUMDISTANCE = 0 C = 0 with arcpy.da.SearchCursor(fc, fields, "FID = 0") as cursor: for row in cursor: DISTANCE = row DURATION = row SUMDISTANCE = SUMDISTANCE + DISTANCE C = C + 1 AVGDISTANCE = SUMDISTANCE / C outFile.write('' + str(AVGDISTANCE) + '\n')
Is this the right format for a point txt?
Point 0 34.5 23.2 12 1 65.7 56.5 67 2 34.9 97.9 43 3 67.2 34.3 20