HI Sangeeta,
'addfiles', like 'addfile'  only works for supported formats -- not for ascii text files. You will need to use asciiread in a loop to read each file in succession.
It will be easier to create a variable that contains all the values for a month's worth of data if you calculate how many elements you need in advance.
For January you could do something like this:
       dir="/root/Desktop/filecsv/"
       files=systemfunc("ls "+dir+"Air*")
       fieldx = new(24 * 31,  float)
       do i = 0, dimsizes(files) - 1
             data = asciiread(files(i),-1,"string")      ; or use data := asciiread(files(i),-1,"string"
             fieldx(i*24:(i+1)*24 - 1) = stringtofloat(str_get_field(data(1:24),x,","))
             ; etc. for each field you want
             delete(data)  
      end do
      ; process each field as needed
This assumes the "ls" command is only getting a month's worth of data. If you are going to do more than a month's worth you will need an outer loop and
the code will need to be elaborated.
This code has not been tested. It is only a suggestion of how to proceed.
 -dave
        
On Aug 6, 2013, at 10:32 PM, sangeeta maharjan <sangeetamaharjan@gmail.com> wrote:
> Dear NCL Users,
> I was able to read a csv file containing hourly air remperature data
> of a day using following code.
> 
> begin
>        filename="/root/Desktop/AirTemperature(1).csv"
>        data=asciiread(filename,-1,"string")
>        delim=","
> 
>        tfs=str_fields_count(data,delim)
> 
>         field1 = (str_get_field(data(1:24),1,","))
>         field2 = (str_get_field(data(1:24),2,","))
>         field3 = stringtofloat(str_get_field(data(1:24),3,","))
>         field4 = stringtofloat(str_get_field(data(1:24),4,","))
>         field5 = stringtofloat(str_get_field(data(1:24),5,","))
> 
> 
>         print ("Date="+field1+"  time="+field2+"   Min="+field3 +"
> Max="+field4+" Avg="+field5)
> 
> end
> 
> But, I need to calculate the monthly average on air temperature for
> which I have to read multiple csv files. I wrote couple of codes which
> are as follows but it didn't work.
> 
> begin
>        dir="/root/Desktop/filecsv/"
>        files=systemfunc("ls "+dir+"Air*")
>        print(files)
>        printVarSummary(files)
>        print(files(0))
> 
>        f    = addfiles (files, "r")
> 
>        ListSetType (f, "cat")
>        data=asciiread(f,-1,"string")
>        delim=","
> 
> end
> 
> Can you please help me to work with multiple csv file ?. For your kind
> reference, I have attached one of my csv file herewith.
> 
> Thanks & Regards,
> Sangeeta Maharjan.
> <Air Temperature (1).csv>_______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Aug  7 12:38:21 2013
This archive was generated by hypermail 2.1.8 : Wed Aug 07 2013 - 13:59:00 MDT