I have more than 300 CSV files. Every CSV file contains different Longitude, Latitude and other parameters (e.g. Date, Longitude, Latitude, Elevation, Max Temperature, Min Temperature, Precipitation, Wind, Relative Humidity, Solar Radiation).
I need to convert CSV to shapefile using ArcGIS Python to automatically loop through every CSV. I have made one code but it takes only a single file, and does not loop through every CSV file.
Below I copied my script which is creating only single shapefile taking from last CSV file. Not creating shapefile from all CSV files
import arcpy,os
... shpworkspace = r"D:\SWAT-WEATHER-DATA2"
... arcpy.env.workspace = shpworkspace
... arcpy.env.overwriteOutput = True
...
... csvlist = arcpy.ListFiles("*.csv")
...
... for csvfile in csvlist:
... print csvfile
... outlayer = "CSVEventLayer"
... spatialreference = "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]];-400 -400 1000000000;-100000 10000;-100000 10000;8.98315284119522E-09;0.001;0.001;IsHighPrecision"
... arcpy.MakeXYEventLayer_management(csvfile,"Longitude","Latitude",outlayer,spatialreference,"#")
...
... shpfile = os.path.splitext(csvfile)[0].replace('-','_')
... arcpy.CopyFeatures_management(outlayer,shpfile)
... del outlayer
...
weatherdata-233688.csv
weatherdata-233691.csv
weatherdata-233694.csv
weatherdata-233697.csv
weatherdata-233700.csv
weatherdata-233703.csv
weatherdata-233706.csv
weatherdata-236688.csv
weatherdata-236691.csv
weatherdata-236694.csv
weatherdata-236697.csv
weatherdata-236700.csv
weatherdata-236703.csv
weatherdata-236706.csv
weatherdata-239688.csv
weatherdata-239691.csv
weatherdata-239694.csv
weatherdata-239697.csv
weatherdata-239700.csv
weatherdata-239703.csv
weatherdata-239706.csv