Re: reading multiple asci files

From: ozan mert gokturk <zanmerto_at_nyahnyahspammersnyahnyah>
Date: Tue, 13 Oct 2009 01:29:18 -0700 (PDT)

 Hi Jonathan
 
 With the method I will suggest, the number of columns in
 each file you read must be the same. Something like the
 following:
 
 file_names = systemfunc("ls *.asc") 
 
 ;returns all .asc files
 
 data_all =
 new((/nfiles,dimsizes(years),dimsizes(months)/),float)
 
 ;define a single multi-dimensional variable for all the
 data you will read. nfiles is the number of files, other
 dimensions depend on what you want to read, you must make
 them as big as possible so that the max number of rows and
 columns in your ascii files fit in. In my case they were
 rows=years and columns=months
 
 iSize=dimsizes(file_names)-1
 do i=0,iSize
 toBeRead = readAsciiTable(file_names(i),ncol,float,(/k,m/)
 ; k and m are the number of rows you will skip at the
 beginning and at the end. ncol is the number of columns
 data_all(i,dimsizes(toBeRead(:,0)),:) = tobeRead
 delete(toBeRead)
 end do
 
 ; this way you will read all your data from the ascii files
 into a single variable.
 
 Good luck
 
 Ozan
 
 --- On Mon, 10/12/09, jwsmith_at_ucar.edu
> <jwsmith_at_ucar.edu>
> wrote:
>
> > From: jwsmith_at_ucar.edu
> <jwsmith_at_ucar.edu>
> > Subject: reading multiple asci files
> > To: ncl-talk_at_ucar.edu
> > Date: Monday, October 12, 2009, 2:52 PM
> > Hello,
> >
> > I have the following command that reads in an ascii
> file:
> >
> > data =
> asciiread("20090401.asc",(/nrows,ncols/),"float")
> >
> > How can one read in multiple .asc files using the
> > systemfunc and 
> > addfiles command with the asciiread stipulations
> above?
> >
> >
> >
> > Jonathan Wynn Smith
> >
> > Doctoral Student in Howard University
> > Program in Atmospheric Sciences (HUPAS)
> > 2008 ASP Graduate Student Visitor
> > 2006 ASP Summer Colloquium Participant
> >
> > 408 Thirkield Building
> > 2355 6th St. NW
> > Washington, DC 20059
> >
> > E-mail: jw_smith_at_howard.edu
> > or jwsmith9_at_gmail.com
> > Cell Phone: 336-601-4563
> >
> >
> ----------------------------------------------------------------
> > This message was sent using IMP, the Internet
> Messaging
> > Program.
> >
> > _______________________________________________
> > 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 Tue Oct 13 2009 - 02:29:18 MDT

This archive was generated by hypermail 2.2.0 : Thu Oct 15 2009 - 09:30:48 MDT