Looping through values

المشرف العام

Administrator
طاقم الإدارة
I have 168 files I need to analyse. They are actually paired, with 84 .csv files named according to a "YearMonth" convention and the other 84 .shp files named "YearMonth_Layer" - ultimately all 84 pairs need to be joined. I am new to scripting with python so I am sure this is a simple application of some general for x in xrange(2006, 2012): syntax, but I do not know the specifics and a search didn't turn up what I need. I need to iterate through the years 2006-2012, and all 12 months in each year to complete the following:

# Import arcpy moduleimport arcpy# Local variables:v200612_csv = "200612.csv"v2006_12 = "2006_12"v2006_12_shp = "Y:\\2006_12.shp"v2006_12_buffer_shp = "Y:\\2006_12_buffer.shp"v200612_Layer_shp = "V:\\Shapefiles\\200612_Layer.shp"v2006_12_buffer_shp__2_ = "Y:\\2006_12_buffer.shp"v200612_Layer_shp__2_ = "V:\\Shapefiles\\200612_Layer.shp"c2006_12_buffer_SpatialJoin = "v:\\Shapefiles\\c2006_12_buffer_SpatialJoin"# Process: Make XY Event Layerarcpy.MakeXYEventLayer_management(v200612_csv, "POINT_X", "POINT_Y", v2006_12, "PROJCS['NAD_1983_2011_StatePlane_New_York_Long_Isl_FIPS_3104_Ft_US',GEOGCS['GCS_NAD_1983_2011',DATUM['D_NAD_1983_2011',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Lambert_Conformal_Conic'],PARAMETER['False_Easting',984250.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-74.0],PARAMETER['Standard_Parallel_1',40.66666666666666],PARAMETER['Standard_Parallel_2',41.03333333333333],PARAMETER['Latitude_Of_Origin',40.16666666666666],UNIT['Foot_US',0.3048006096012192]];-120039300 -96540300 3048.00609601219;-100000 10000;-100000 10000;3.28083333333333E-03;0.001;0.001;IsHighPrecision", "")# Process: Feature Class To Shapefile (multiple)arcpy.FeatureClassToShapefile_conversion("2006_12", mfriedma)# Process: Bufferarcpy.Buffer_analysis(v2006_12_shp, v2006_12_buffer_shp, "1000 Feet", "FULL", "ROUND", "NONE", "", "PLANAR")# Process: Spatial Joinarcpy.SpatialJoin_analysis(v2006_12_buffer_shp__2_, v200612_Layer_shp__2_, c2006_12_buffer_SpatialJoin, "JOIN_ONE_TO_MANY", "KEEP_ALL", "POINT_X \"POINT_X\" true true false 19 Double 0 0 ,First,#,Y:\\2006_12_buffer.shp,POINT_X,-1,-1;POINT_Y \"POINT_Y\" true true false 19 Double 0 0 ,First,#,Y:\\2006_12_buffer.shp,POINT_Y,-1,-1;paper_ID \"paper_ID\" true true false 10 Long 0 10 ,First,#,Y:\\2006_12_buffer.shp,paper_ID,-1,-1;year \"year\" true true false 10 Long 0 10 ,First,#,Y:\\2006_12_buffer.shp,year,-1,-1;month \"month\" true true false 10 Long 0 10 ,First,#,Y:\\2006_12_buffer.shp,month,-1,-1;BUFF_DIST \"BUFF_DIST\" true true false 19 Double 0 0 ,First,#,Y:\\2006_12_buffer.shp,BUFF_DIST,-1,-1;ORIG_FID \"ORIG_FID\" true true false 10 Long 0 10 ,First,#,Y:\\2006_12_buffer.shp,ORIG_FID,-1,-1;datestop \"datestop\" true true false 254 Text 0 0 ,First,#,V:\\Shapefiles\\200612_Layer.shp,datestop,-1,-1;datestop_X \"datestop_X\" true true false 19 Double 0 0 ,First,#,V:\\Shapefiles\\200612_Layer.shp,datestop_X,-1,-1;datestop_Y \"datestop_Y\" true true false 19 Double 0 0 ,First,#,V:\\Shapefiles\\200612_Layer.shp,datestop_Y,-1,-1;xcoord \"xcoord\" true true false 9 Long 0 9 ,First,#,V:\\Shapefiles\\200612_Layer.shp,xcoord,-1,-1;ycoord \"ycoord\" true true false 9 Long 0 9 ,First,#,V:\\Shapefiles\\200612_Layer.shp,ycoord,-1,-1;precinct \"precinct\" true true false 9 Long 0 9 ,First,#,V:\\Shapefiles\\200612_Layer.shp,precinct,-1,-1;year_1 \"year_1\" true true false 9 Long 0 9 ,First,#,V:\\Shapefiles\\200612_Layer.shp,year,-1,-1;month_1 \"month_1\" true true false 9 Long 0 9 ,First,#,V:\\Shapefiles\\200612_Layer.shp,month,-1,-1;date \"date\" true true false 9 Long 0 9 ,First,#,V:\\Shapefiles\\200612_Layer.shp,date,-1,-1", "CONTAINS", "", "")

أكثر...
 
أعلى