read ascii

From DavinciWiki
(Redirected from Read ascii)
Jump to: navigation, search


Description

The read_ascii() function loads data from an ASCII columnar (matrix) file.

Identical to ascii.

The data is assumed to be in BSQ organization.

Arguments and Return Values

Parameters: The path and filename of a file containing delimited numeric data.

Return Value: A matrix of numbers of specified data type.

Usage

Syntax: read_ascii(filename = STRING, x = INT, y = INT, z = INT, format = TYPE, column = INT, row = INT, delim = STRING)

Pixel values on a line must be separated by at least one space or tab. Lines must be seperated by exactly 1 newline, and planes must be separated by 1 blank line.

The only required keyword is 'filename'. If any of the X, Y or Z values are omitted, they are assumed to be 1, unless all are omitted, in which case the file is pre-scanned to attempt to determine its size.

'Format' determines the output type of the data. TYPE is one of: 'byte', 'short', 'int', 'float', or 'double'. If format is omitted, the default output type is INT. Floating point values cannot be read using a type of 'byte', 'short' or 'int'.

The value 'row' specifies the number of lines to skip before trying to read any data. The value 'column' specifies the number of values to skip for every line read.

The 'delim' parameter defines the list of column delimiters to use. If this option is omitted, the both TAB and SPACE are used as delimiters. The value for 'delim' should always be enclosed in quotes.

Examples

 dv> z=read_ascii("/work/user/asciifile")
 Apparent file size: 3x3x1
 3x3x1 array of int, bsq format [36 bytes]
 1       6       0
 1       6       0
 1       6       0

 dv> z=read_ascii("/work/user/asciifile",format=int)
 Apparent file size: 3x3x1
 3x3x1 array of int, bsq format [36 bytes]
 1       6       0
 1       6       0
 1       6       0

 dv> z=read_ascii("/work/user/asciifile",format=float)
 Apparent file size: 3x3x1
 3x3x1 array of float, bsq format [36 bytes]
 1.72092 6.11169 0.0804656
 1.58156 6.67035 0.297082
 1.49277 6.01372 0.518543

DavinciWiki Mini-Nav Bar

Contents


Contact Developers

  • davinci-dev [AT] mars.asu.edu

All other topics

  • See navigation on the left

Related Functions

Recent Core Changes

Modified On: 02-15-2007

Personal tools