Skip to content


Read text from a file or process handle

read0 f           read0[f]
read0 (f;o;n)     read0[(f;o;n)]
read0 h           read0[h]
read0 (fifo;n)    read0[(fifo;n)]


returns character data from the source as follows.

File symbol

Returns the lines of the file as a list of strings. Lines are assumed delimited by either LF or CRLF, and the delimiters are removed.

q)`:test.txt 0:("hello";"goodbye")  / write some text to a file

q)/ read 500000 lines, chunks of (up to) 100000 at a time
q)d:raze{read0(`:/tmp/data;x;100000)}each 100000*til 5

File descriptor

Returns n chars from the file, starting from the position o.

q)`:foo 0: enlist "hello world"
q)read0 (`:foo;6;5)

System or process handle

Returns a line of text from the source.

q)rl:{1">> ";read0 0}
>> xiskso

Reading the console permits interactive input.

q)1">> ";a:read0 0
>> whatever
q)a[4+til 4]

Fifo/named pipe

Returns n characters from the pipe. (Since V3.4 2016.05.31)

"Red Hat "

Connection handles, File system, Interprocess communication
Q for Mortals §11.4.1 Reading and Writing Text Files

Back to top