Data & I/O
ilo has built-in support for reading and writing files, making HTTP requests, and accessing environment variables. All I/O builtins return R (Result) types - use ! to auto-unwrap.
Reading files
Section titled “Reading files”rd path reads a file with format auto-detected from the extension:
| Extension | Returns |
|---|---|
.csv | R _ t — list of lists (grid) |
.tsv | R _ t — list of lists (grid) |
.json | R _ t — parsed JSON value |
| other | R _ t — raw text string |
load p:t>R _ t;rd pForce a specific format with a second argument:
load p:t>R _ t;rd p "json"Reading lines
Section titled “Reading lines”rdl path reads a file as a list of lines:
lines p:t>R L t t;rdl pParsing buffers
Section titled “Parsing buffers”rdb string format parses a string in a given format - useful for data received from HTTP responses:
parse s:t>R _ t;rdb s "json"Writing files
Section titled “Writing files”wr path data writes data to a file. Format can be specified as a third argument:
save>R t t;wr "out.txt" "hello world"Structured output with format:
csv>R t t;wr "out.csv" [[1,2],[3,4]] "csv"json>R t t;wr "data.json" [1,2,3] "json"HTTP requests
Section titled “HTTP requests”get url makes an HTTP GET request. $url is a terse alias:
fetch url:t>R t t;$urlAuto-unwrap with ! to skip Result handling:
fetch url:t>t;$!urlpost url body makes an HTTP POST:
send url:t body:t>R t t;post url bodyCustom headers
Section titled “Custom headers”Build a header map with mmap/mset and pass it as the last argument:
fetch url:t key:t>R t t h=mmap h=mset h "Authorization" key get url hPOST with custom headers works the same way:
send url:t body:t key:t>R t t h=mmap h=mset h "x-api-key" key post url body hHTTP builtins (
get,$,post) require the native binary. The npm/WASM build does not support network access.
Environment variables
Section titled “Environment variables”env key reads an environment variable, returning R t t:
home>R t t;env "HOME"Auto-unwrap with !:
home>t;env! "HOME".env and .env.local files in the working directory are loaded automatically.