[Thread Prev][Thread Next][Index]

Re: [ferret_users] Reading ascii data



Hi Ben,
         By default, Ferret reads ascii files along columns rather than along
rows, irrespective of the "delimiter" used. Depending on the grid specified,
entries in the first column will be assigned to first variable, entries in the
second column will be assigned to second variable and so on. To force Ferret
to read "along the row/line", you have to use /COLUMNS qualifier with proper
value, to FILE command. A simple example is shown below. 

  Please note that Ferret Documentation covers almost all aspects of handling
ASCII data. For example, "Ch2 Sec5.  ASCII DATA" contains detailed explanations
about different commands/qualifiers with very good examples. Also the very next
section, Ch2 Sec6. TRICKS TO READING BINARY AND ASCII FILES, explains some
trics to handle ASCII data sets with non-standardized formats.

  It is always a good habit to convert the ascii data to NetCDF format in
Ferret, after assigning proper grid/title/units etc., for future use. 

Hope this helps....

Regards,

Jaison


!------example for reading ASCII data along row------------------
\cancel mode verify
!
! suppose the txt file ascii_columns.dat contains just the following line
!
!     1 2 3 4 5 6 7 8 9 10
!
! Then the following method will show up only one value

      define axis/t=1:10:1 tax
      define grid/t=tax gfile
      file/grid=gfile/var=p ascii_column.dat
      list p
!
! But the /COLUMNS=10 qualifier will make all values available
!
      file/grid=gfile/columns=10/var=p1 ascii_column.dat
      list p1

!-----end of example---------------------------------------------------


On Sat, 17 Feb 2007, Ben Burford wrote:

> Hello All,
> 
> I have a very simple problem, but alas. . . .
> 
> I have ascii integer data that is space separated.  I can also create a comm
> a separated file but space separated is easier.  Its a continuous stream of 
> values (1095 values, which is 3 years of daily precipitation data) with no c
> arriage returns.  I haven't been successfull in reading either type (space s
> eparated or comma separted).
> 
> I tried variations on:
> define axis/t=1:1095:1/units=days  tax
> define grid/t=tax aaa
> file/grid=aaa/var=p file.dat
> 
> I also tried variations on stream (I think stream is for binary data, but do
> es type=text handle ascii data?):
> define axis/t=1:1095:1/units=days  tax
> define grid/t=tax aaa
> set data/format=delimited/delimiters="\b"/type=text/grid=aaa/var=p  file.dat
>   (note: in this line "\b" is backslash b for blank).
> 
> In both cases if I do a "list p" I only I find that I've read in only one da
> ta value.
> 
> Surely this must be a simple thing - read in a string of ascii values, eithe
> r space or comma delimited (I could also convert the commas to tabs as delim
> iters).
> 
> Please show me how to do this.
> 
> Thank you,
> 
> Ben
> 
> 
> 


[Thread Prev][Thread Next][Index]

Contact Us
Dept of Commerce / NOAA / OAR / PMEL / TMAP

Privacy Policy | Disclaimer | Accessibility Statement