I have hundreds of CSV files with the naming convention similar to:
prcp_025_01_01.csv prcp_025_05_01.csv prcp_025_08_01.csv prcp_050_01_01.csv prcp_050_05_01.csv prcp_050_08_01.csv prcp_025_01_15.csv prcp_025_05_15.csv prcp_025_08_15.csv I was wanting to create a shapefile for each CSV like so:
prcp_025_01_01.shp prcp_025_05_01.shp prcp_025_08_01.shp prcp_050_01_01.shp prcp_050_05_01.shp prcp_050_08_01.shp prcp_025_01_15.shp prcp_025_05_15.shp prcp_025_08_15.shp When running the following code, it will create the first shapefile of prcp_025_01_01.shp But then error out with
ERROR 000725: Layer Name or Table View: Dataset prcp_dly_layer already exists. Failed to execute (MakeXYEventLayer).
Im running 10.5.1 Below is my script. Any suggestions on how to fix it?
import arcpy import os arcpy.env.workspace=r"C:\path" shps=arcpy.ListFeatureClasses() SR=arcpy.SpatialReference(4269) #WGS 1984 for shp in shps: print arcpy.Describe(shp).spatialReference.name elem = ["025", "050", "100", "400"] month = ["01", "05", "08", "12"] day = ["01", "15", "31"] for element in elem: for mon in month: for dy in day: in_table=r"C:\path\csv_files/prcp_" + element + "_" + mon + "_" + dy + ".csv" prcp_dly_layer=arcpy.MakeXYEventLayer_management(in_table, "LON", "LAT", "prcp_dly_layer", SR) fc=arcpy.CopyFeatures_management(prcp_dly_layer, r"C:\path\prcp/" + "prcp_" + element + "_" + mon + "_" + dy + "_" + '.shp') print(arcpy.GetCount_management(prcp_dly_layer))