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

问题描述 投票:0回答:1

我的python技能非常有限(没有)我从未创建过ArcMap的自动顺序请求。以下是我想编码的步骤,任何建议都将不胜感激。

  1. 找到文件夹
  2. 导入“第一个”文件(表csv)(有超过500个cvs,命名约定不是顺序的)
  3. 将csv加入HUC08 shapefile
  4. 在字段名称“名称”下选择没有Null值的数据
  5. 将所选数据保存为我的FoTX.gdb中的图层文件
  6. 移至文件夹中的下一个文件并完成相同的操作,直到所有操作完成。
python sequential arcmap
1个回答
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"
© www.soinside.com 2019 - 2024. All rights reserved.