asciiread

This function is used to read in files that contain ASCII representations of basic data types.


Synopsis

	function asciiread( 
		filepath[1]:string,
		dimensions[*]:integer,
		datatype[1]:string
	)

Arguments

filepath
Path needed to locate ASCII file.
dimensions
An array specifying the dimensions of the data to be read or -1 if dimensions are unknown.
datatype
A string representing the type of the data being read.

Description

The asciiread function is used to read in ascii data. For numeric types, all other characters are ignored and the numbers are read in the order they appear in the input file. For string data, each line of the file is read as a string. For character data, the file is read byte-by-byte.

An error message is generated whenever the number of elements read is less than the number implied by the dimensions parameter.

If -1 is given for the dimension sizes, all values in the file will be read into a single dimension variable. The dimension size of this variable will be equal to the number of elements in the file.


Example

If you have an ASCII data file called "data.asc" that looks like this:
 1.  2.  3.
 4.  5.  6.
 7.  8.  9.
10. 11. 12.
13. 14. 15.
then you can read it various ways as shown with the following ncl script:
begin  
  z1 = asciiread("data.asc",(/5,3/),"float")
  z2 = asciiread("data.asc",(/4,2/),"float")
end
The results of z1 and z2 would be:
z1(0,0) = 1.
z1(0,1) = 2.
z1(0,2) = 3.
z1(1,0) = 4.
z1(1,1) = 5.
z1(1,2) = 6.
z1(2,0) = 7.
.
.
.
z1(4,0) = 13.
z1(4,1) = 14.

z2(0,0) = 1.
z2(0,1) = 2.
z2(1,0) = 3.
z2(1,1) = 4.
z2(2,0) = 5.
z2(2,1) = 6.
z2(3,0) = 7.
z2(3,1) = 8.

Example of using -1:
begin
	z3 = asciiread("data.asc",-1,"float")
end
z3(0) = 1.
z3(1) = 2.
z3(2) = 3.
.
.
.

Reference Manual Control Panel

NG4.1 Home, Index, Examples, Glossary, Feedback, Ref Contents, Ref WhereAmI?


$Revision: 1.11 $ $Date: 1998/07/06 22:37:00 $