AnsweredAssumed Answered

ArcPy Error: Date' is not in list, While extracting monthly data from timeseries NetCDF

Question asked by india123 on Mar 7, 2017
Latest reply on Mar 23, 2017 by Dan_Patterson

Hi All, 

I have one NetCDF file, that contain monthly value for the different year (1910 - 2014). I want to extract few years data (e.g 2000 - 2014), date range reading from a csv file  and save it as a raster map as the  name format of year-month-date.  I am working on below script but I am getting error 

Below i have attached the csv file which i am using for date range purpose. 

Any help would be greatly appreciated! Thanks 

The image showing the format of Year-month-date



Error massage 

Traceback (most recent call last):
  File "<module4>", line 18, in <module>
ValueError: 'Date' is not in list

Here what i have  so far 

import os, sys
import arcpy

# Check out any necessary licenses
arcpy.env.overwriteOutput = True

# Script arguments
netCDF = "C:\\Users\\Downloads\\SPIE"
rainfall = "C:\\Users\\Downloads\\SPIE\\New folder"

arcpy.env.workspace = netCDF

# Read Date from csv file
eveDate = open ("C:\\Users\\Downloads\\SPIE\\Name1.csv")
headerLine = eveDate.readline()
valueList = headerLine.split(",")
dateValueIndex = valueList.index("Date")
eventList = []
for line in eveDate.readlines():
    segmenLine = line.split(",")
    variable = "spei"
    x_dimension = "lon"
    y_dimension = "lat"
    band_dimension = ""

for year in range(2010):
    nc_name = '' % (year,)
    valueSelectionMethod = "BY_VALUE"
    outFile = "Pre"
    # extract dimensionValues from csv file
    arcpy.MakeNetCDFRasterLayer_md("", variable, x_dimension, y_dimension, outFile, band_dimension, segmenLine[dateValueIndex], valueSelectionMethod)
    print "layer done"
    #copy and save as raster tif file
    arcpy.CopyRaster_management(outFile, rainfall + segmenLine[dateValueIndex] + ".tif" , "", "", "", "NONE", "NONE", "")
    print "raster done"