I have scripted a series 10 files that are run daily in order to generate an interpolation of data. However, I periodically have encountered errors where not all of the .csv data is being translated into the .shp file. I have already verified that the data within the .csv file is correct by verifying it against the others I introduce into ArcPy by plotting the data in ArcMap using "Display XY Data".
The script is designed to be dynamic in the sense that all shapefiles are created and saved into a unique YMD folder. The script used to generate .shp files is as follows:
import arcpy import sys from arcpy import env from datetime import datetime, timedelta date0 = datetime.strftime(datetime.now(), '%Y%m%d') # Set environment settings env.workspace = r"C:/somepath/data/"+date0+"/" #Overwrite Old Files (0=No, 1=Yes) arcpy.env.overwriteOutput = 1 try: # Set the local variables in_Table = "C:/somepath/data/"+date0+"/"+date0+"00_d0_tempfile.csv" x_coords = "lon" y_coords = "lat" z_coords = "maxt" out_Layer = "d0points_layer" saved_Layer = "d0points.lyr" # Set the spatial reference spRef = arcpy.SpatialReference("WGS 1984") # Make the XY event layer arcpy.MakeXYEventLayer_management(in_Table, x_coords, y_coords, out_Layer, spRef, z_coords) # Save to a layer file arcpy.SaveToLayerFile_management(out_Layer, saved_Layer) #=============================================================================== # Copy features to shapefile arcpy.CopyFeatures_management("C:/somepath/data/"+date0+"/d0points.lyr", "C:/somepath/data/"+date0+"/d0points.shp") #=============================================================================== except: print arcpy.GetMessages() print 'd0 Data Conversion Complete' sys.exit()
A key question as I sort this out is would it be beneficial to convert the .csv to a .gdb, then proceed with the conversion to .shp?