Python顺序请求:ArcMap中的数据处理自动化

时间:2019-03-05 17:08:39

标签: python sequential arcmap

我的python技能非常有限(没有),而且我从未为ArcMap创建自动的顺序请求。以下是我要编码的步骤,我们将不胜感激。

  1. 找到文件夹
  2. 导入“第一个”文件(表csv)(超过500个cvs,命名约定不是顺序的)
  3. 将csv加入HUC08 shapefile
  4. 在字段名称“名称”下选择不包含Null值的数据
  5. 将所选数据另存为我的FoTX.gdb中的图层文件
  6. 移动到文件夹中的下一个文件并完成相同的操作,直到完成所有操作。

1 个答案:

答案 0 :(得分:0)

#Part of the code. The rest depends mostly on your data
#Set environment settings
arcpy.env.workspace = 'C:/data' #whatever it is for you. you can do this or not


import os, arcpy, csv

   mxd = arcpy.mapping.MapDocument("CURRENT")
   folderPath=os.path.dirname(mxd.filePath)

   #Loop through each csv file
    count = 0

    for f_name in os.listdir(folderPath):
      fullpath = os.path.join(folderPath, f_name)
      if os.path.isfile(fullpath):
       if f_name.lower().endswith(".csv"):
             #import csv file and join to shape file code here

             # Set local variables
             in_features = ['SomeNAME.shp', 'SomeOtherNAME.shp'] # if there are more 
                                                                 #then one
             out_location = 'C:/output/FoTX.gdb'
             # out_location =os.path.basename(gdb.filePath) #or if the gdb is in the 
                                                            #same folder as the csv 
                                                            #files

             # Execute FeatureClassToGeodatabase
             arcpy.FeatureClassToGeodatabase_conversion(in_features, out_location)

    if count ==0:
      print "No CSV files in this folder"