I am unable to figure a way out how to create a shapefile after looping through the csv files and matching the headers (dates in format Oct11/2018). Each shapefile should have all the fields with the date that matches the header. In this way I want to create multiple shapefiles for each single date and with the date as the name of the shapefile.
import pandas as pd
import numpy as np
import glob
import csv
import arcpy,os
from arcpy import env
arcpy.env.workspace = "D:/datasets/regression_interpolation_rasters/gst_airtemp/excels_shapefiles"
path = "D:/datasets/regression_interpolation_rasters/gst_airtemp/excels_shapefiles"
#arcpy.env.overwriteOutput = True
scratchGDB = arcpy.env.scratchGDB
csvlist = glob.glob(path + "/*.csv")
headers_dict = dict()
for filename in all_csv:
#print(filename)##15
df = pd.read_csv(filename, index_col= None, header=0, parse_dates = True, usecols=lambda x: x not in ["Stat_name","Name", "Altitude", "Lat", "Long"])
#print(df)
#print(type(df))
headers_dict[filename] = df.columns
#print(type(headers_dict))
for csvfile in csvlist:
#print(csvfile)##24
headers = pd.read_csv(csvfile, index_col= None, header=0, parse_dates = True, usecols=lambda x: x not in ["Stat_name","Name", "Altitude", "Lat", "Long"])
#print(headers)
#print(type(headers))
headers_dict = headers
arcpy.TableToTable_conversion(csvfile, scratchGDB, "CSV")
outLayer = "date"
#print(table)
#print(type(table))
spatialreference = arcpy.SpatialReference(32632)
arcpy.MakeXYEventLayer_management(os.path.join(scratchGDB, "CSV"), "Long","Lat",outLayer,spatialreference,"Altitude")
arcpy.FeatureClassToShapefile_conversion(outLayer, path)
arcpy.MakeFeatureLayer_management(outLayer, "outLayer_lyr")
arcpy.SelectLayerByAttribute_management("outLayer_lyr", "NEW_SELECTION")
Here is one example using an image
This is the csv file converted to shapefile with all the dates
Converted shapefile I want
I have a few questions