ReadList
✖
ReadList
Details and Options


- Possible types to read are:
-
Byte single byte, returned as an integer code Character single character, returned as a one‐character string Expression complete Wolfram Language expression Number integer or an approximate number, given in "E" format Real approximate number, given in "E" format Record sequence of characters delimited by record separators String string terminated by a newline Word sequence of characters delimited by word separators - 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 Wolfram Language 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.
- The following options can be given:
-
NullRecords False whether to assume a null record between repeated record separators NullWords False whether to assume a null word between repeated word separators RecordSeparators {"\r\n","\n","\r"} separators allowed between records RecordLists False create separate sublists for each record TokenWords {} words taken as delimiters WordSeparators {" ","∖t"} separators allowed between words - If file is not already open for reading, ReadList opens it, then closes it when it is finished. If the file is already open, ReadList does not close it at the end.
- ReadList prints a message if any of the objects remaining in the file are not of the specified types.
- ReadList["file",{type1,…}] looks for the sequence of typei in order. If the end of file is reached while partway through the sequence of typei, EndOfFile is returned in place of the elements in the sequence that have not yet been read.
- ReadList[stream] reads from an open input stream, as returned by OpenRead.
- ReadList works with cloud objects.
- File["file"] may be used to specify a file name.
Examples
open allclose allBasic Examples (2)Summary of the most common use cases
Scope (2)Survey of the scope of standard use cases
Read an expression from the file specified by the File object:

https://wolfram.com/xid/0e7pr3o6-bn797w


https://wolfram.com/xid/0e7pr3o6-zh5d3x

https://wolfram.com/xid/0e7pr3o6-fiwh5o

https://wolfram.com/xid/0e7pr3o6-dt8hhb


https://wolfram.com/xid/0e7pr3o6-2hznj3

https://wolfram.com/xid/0e7pr3o6-zl6n2w

Read three numbers from the stream:

https://wolfram.com/xid/0e7pr3o6-1o840y

Read two words from the stream:

https://wolfram.com/xid/0e7pr3o6-2lmyim


https://wolfram.com/xid/0e7pr3o6-70vj2x

Read all remaining data in the stream as expressions:

https://wolfram.com/xid/0e7pr3o6-egooir

Any further attempt to read from the stream will return an empty list:

https://wolfram.com/xid/0e7pr3o6-9glfc7


https://wolfram.com/xid/0e7pr3o6-zrn0hs

Possible Issues (1)Common pitfalls and unexpected behavior
Some streams, like those created by StringToStream, give values greater than 255 for the Byte type:

https://wolfram.com/xid/0e7pr3o6-lfiijg

https://wolfram.com/xid/0e7pr3o6-1nno92


These correspond to the individual character codes:

https://wolfram.com/xid/0e7pr3o6-job4ip


https://wolfram.com/xid/0e7pr3o6-5v5q5o

Wolfram Research (1988), ReadList, Wolfram Language function, https://reference.wolfram.com/language/ref/ReadList.html (updated 2016).
Text
Wolfram Research (1988), ReadList, Wolfram Language function, https://reference.wolfram.com/language/ref/ReadList.html (updated 2016).
Wolfram Research (1988), ReadList, Wolfram Language function, https://reference.wolfram.com/language/ref/ReadList.html (updated 2016).
CMS
Wolfram Language. 1988. "ReadList." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2016. https://reference.wolfram.com/language/ref/ReadList.html.
Wolfram Language. 1988. "ReadList." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2016. https://reference.wolfram.com/language/ref/ReadList.html.
APA
Wolfram Language. (1988). ReadList. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ReadList.html
Wolfram Language. (1988). ReadList. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ReadList.html
BibTeX
@misc{reference.wolfram_2025_readlist, author="Wolfram Research", title="{ReadList}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/ReadList.html}", note=[Accessed: 29-March-2025
]}
BibLaTeX
@online{reference.wolfram_2025_readlist, organization={Wolfram Research}, title={ReadList}, year={2016}, url={https://reference.wolfram.com/language/ref/ReadList.html}, note=[Accessed: 29-March-2025
]}