This is documentation for Mathematica 4, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

Put (>>)Run

Read

FilledSmallSquareRead[stream] reads one expression from an input stream, and returns the expression.

FilledSmallSquareRead[stream, type] reads one object of the specified type.

FilledSmallSquareRead[stream, , , ... ] reads a sequence of objects of the specified types.

FilledSmallSquare Possible types to read are:

FilledSmallSquare Objects of type Real can be given in the scientific notation format used by languages such as C and Fortran, as well as in standard Mathematica format. A form like 2.e5 or 2E5 as well as 2*^5 can be used to represent the number . Objects read as type Real are always returned as approximate numbers. Objects read as type Number are returned as integers if they contain no explicit decimal points.

FilledSmallSquare The following options can be given:

FilledSmallSquare Objects of type String must be terminated by newlines ("\n" characters).

FilledSmallSquare You can specify any nested list of types for Read to look for. Each successive object read will be placed in the next position in the list structure. A depth-first traversal of the list structure is used.

FilledSmallSquare Example: Read[stream, Number, Number] reads a pair of numbers from an input stream, and gives the result as a two-element list.

FilledSmallSquareRead[stream, Number, Number, Number, Number] reads a matrix, going through each column, then each row.

FilledSmallSquare You can use Read to get objects to insert into any expression structure, not necessarily a list. Example: Read[stream, Hold[Expression]] gets an expression and places it inside Hold.

FilledSmallSquare The first argument to Read can be InputStream["name", n], or simply "name" if there is only one open input stream with the specified name.

FilledSmallSquare You can open a file or pipe to get an InputStream object using OpenRead.

FilledSmallSquare There is always a "current point" maintained for any stream. When you read an object from a stream, the current point is left after the input you read. Successive calls to Read can therefore be used to read successive objects in a stream such as a file.

FilledSmallSquareRead returns EndOfFile for each object you try to read after you have reached the end of a file.

FilledSmallSquareRead returns $Failed if it cannot read an object of the type you requested.

FilledSmallSquare If there is a syntax error in a Mathematica expression that you try to read, then Read leaves the current point at the position of the error, and returns $Failed.

FilledSmallSquare See The Mathematica Book: Section 2.11.8.

FilledSmallSquare See also: Input, Get, Skip, Find, StringToStream, LinkRead, Import.

Put (>>)Run