read numerical data from text files
readdata(fileID, format, n)
symbol or string; file name or file descriptor of the data file
positive integer; specifies the number of columns of data
integer, float, or string or a list containing these names; specifies the format of the data that is read
The readdata function reads numeric data from a text file into Maple. The data in the file must consist of integers or floating-point values arranged in columns, separated by white space.
If only one column of data is read, the output is a list of the data. If more than one column is read, the output is a list of data corresponding to the rows of data in the file for the specified columns.
To read numerical data and store it in a Matrix or Vector, see ImportMatrix and ImportVector.
The first form of the calling sequence for the readdata function reads n columns of numerical data in floating-point format from the file specified by fileID.
The second and third calling sequence for readdata specify whether the data is read as integer, floating-point, or string data. The format parameter must be one of integer, float, or string, or a list containing one or more of these.
Note: The procedure readline is used to read a line of data from the file and the data is extracted by using sscanf.
While integers can be read as floating-point numbers, floating-point numbers should not be read in as integers.
If a file name is specified (instead of a file descriptor), and the file is not already open, the file will be opened as a TEXT file in READ mode. Furthermore, if a file name is specified, the file is closed when readdata returns.
Note: The writedata function is the corresponding function for writing numerical data into a file.
Suppose that the example file data contains the following data.
Read three columns of floating-point numbers from the file data.
Read three columns as integers.
Read the first column of data as integers.
Read the first column of data as floating-point numbers.
Read the first two columns as integers and the third column as floating-point numbers.
Download Help Document