QStudio
Query kdb+ Servers and Chart Results.
kdb provides the following IO/file commands for outputting, writing and reading files.
sym | description | eg |
---|---|---|
getenv | Returns the value of the given environment variable. | getenv `PATH |
hcount | Gets the size in bytes of a file as a long integer. | hcount`:c:/q/test.txt |
hsym | Converts its symbol argument into a file name, or valid hostname, ipaddress | hsym`10.43.23.197 |
read0 | The read0 function reads a text file, returning a list of lines.Lines are assumed delimited by either LF or CRLF, and the delimiters are removed. | read0`:test.txt |
read0 | Optionally, read0 can take a three-item list as its argument, containing the file handle, an offset at which to begin reading, and a length to read. | read0(`:/tmp/data;0;0+100000) |
read1 | The read1 function reads a file as a list of bytes. | read1`:test.txt |
read1 | Optionally, read1 can take a three-item list as its argument, containing the file handle, an offset at which to begin reading, and a length to read. | read1(`:/tmp/data;0;0+100000) |
rload | The rload function loads a splayed table. This can also be done, as officially documented, using the get function. | |
save | The save function saves data to the filesystem. | t:([]x: 1 2 3; y: 10 20 30);save `t |
set | Dyadic functional form of assignment often used when saving objects to disk. set is used mainly to write data to disk and in this case the left argument is a file path, i.e. a symbol atom beginning with a : | `:c:/q/testTradeTable set trade |
setenv | Dyadic function which changes or adds an environment variable. | `name setenv value |
0: | Prepare. The dyadic prepare text function takes a separator character as its first argument and a table or a list of columns as its second. The result is a list of character strings containing text representations of the rows of the second argument separated by the first. | show csv 0: ([]a:1 2 3;b:`x`y`z) |
0: | Save. The dyadic save text function takes a file handle as its first argument and a list of character strings as its second. The strings are saved as lines in the file. The result of the prepare text function can be used as the second argument. | |
0: | Load. The dyadic load text function takes file format description as its first argument and a file handle or a list of character strings as its second. | t:("SS";enlist" ")0:`:/tmp/txt /load 2 columns from space delimited file |
0: | The format description takes the form of a list of types and either a list of widths for each field if the data to be loaded is fixed width, or the delimiter if delimited, if the delimiter is enlisted the first row of the input data will be used as column names and the data is loaded as a table, otherwise the data is loaded as an list of values for each column. | t:("IFC D";4 8 10 6 4) 0: `:/q/Fixed.txt /reads a text file containing fixed length records |
0: | Optionally, load text can take a three-item list as its second argument, containing the file handle, an offset at which to begin reading, and a length to read. | ("SS";csv)0:(`:/tmp/data.csv;x;x+100000) |
0: | Also works for key/value pairs. | show "S=;"0:"one=1;two=2;three=3" |
1: | The 1: dyadic function is used to read fixed length data from a file or byte sequence. The left argument is a list of types and their widths to read, and the right argument is the file handle or byte sequence. | ("ich";4 1 2)1:0x00000000410000FF00000042FFFF |
1 | Write to standard output | 1 "String vector here " |
2 | write to standard error | 2 "String vector here " |
Query kdb+ Servers and Chart Results.