1

my python skills are very limited (to none) and I've never created an automated, sequential request for ArcMap. Below are the steps I'd like to code, any advice would be appreciated.

  1. Locate File folder
  2. Import “first” file (table csv) (there are over 500 cvs, the naming convention is not sequential)
  3. Join csv to HUC08 shapefile
  4. Select data without Null values within under the field name “Name”
  5. Save selected data as a layer file within my FoTX.gdb
  6. Move to the next file within the folder and complete the same action until all actions are complete.
Inigo
  • 12,186
  • 5
  • 41
  • 70
Johanna
  • 11
  • 2

1 Answers1

1
#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"
iMOCKusALL
  • 21
  • 3