Group: | Reading and Writing |
See also: | write read readm |
Function: | readascii | |
Description: | readascii is a command to read ASCII data from a file. |
Usage: | {data, type} = readascii (filename, separator {, check}) | |
Input: | ||
filename | string with the name of the file to be read | |
separator | string with field separators | |
check | determine type (default 1) | |
Output: | ||
data | n x 1 string(!) vector | |
type | n x 1 numeric vector |
The types returned are: 0 (number), 1 (missing), 10 (text), 20 (newline).
w = readascii("geyser", " \t\n") w
Contents of w.data [ 1,] "0.360000E+01" [ 2,] "79." [ 3,] " " [ 4,] "0.180000E+01" [ 5,] "54." [ 6,] " " ... [814,] "0.446667E+01" [815,] "74." [816,] " " Contents of w.type [ 1,] 0 [ 2,] 0 [ 3,] 20 [ 4,] 0 [ 5,] 0 [ 6,] 20 ... [814,] 0 [815,] 0 [816,] 20
w = readascii("geyser", " \t\n", 0) w
Contents of w.data [ 1,] "0.360000E+01" [ 2,] "79." [ 3,] " " [ 4,] "0.180000E+01" [ 5,] "54." [ 6,] " " ... [814,] "0.446667E+01" [815,] "74." [816,] " " Contents of w.type [ 1,] 10 [ 2,] 10 [ 3,] 20 [ 4,] 10 [ 5,] 10 [ 6,] 20 ... [814,] 10 [815,] 10 [816,] 20