Building input expression for CellStatistic in python

Discussion created by davisam1 on Mar 8, 2012
Latest reply on Mar 8, 2012 by davisam1
Hi all,
I have a bunch of rasters (in grid format) in a folder that I want to add up using the Cell Statistic tool.
Here is the python code I wrote:
env.workspace = "D:\\DATA\\MONK_P\\DATA\\NDVI2\\OUT\\"

expression_A = ""
    for filename2 in arcpy.ListRasters("*qual*","GRID"):
        expression_A = "\""+filename2 + "\","+expression_A
        print "no grid rasters"
expression_A = expression_A[:-1]
expression_A = str(expression_A)
expression_A = [expression_A]
print str(expression_A)

Qual_f = out_workspace + "\\Qual_f"
NDVI_f = out_workspace + "\\NDVI_f"

out4 = CellStatistics(expression_A,"SUM","DATA")

This does not work.  I suspect it is because of how I build my expression.  I have looked at the online help file and it looks like I am building it just as they suggest (see http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//009z0000007q000000.htm).  I have tried removing the double quotes around the files and lots of other things to no avail.  I've checked that the files I am trying to add are in the workspace I specify and that the names match up.  I don't know what else to try...

Does anyone know what is going on? 

Thank you in advance for your help,