Skip to content

File I/O

Devlish provides native keywords for reading structured files, writing output, and performing filesystem operations. Each compiles to a dedicated opcode and dispatches through the host runtime.

Read JSON from "config.json" as config
server equals host of config

Returns a parsed record or list.

Read CSV from "invoices.csv" as invoices
For each row in invoices:
Print amount of row

Returns a list of records with column headers as field names.

Read XLSX cell "Sheet1!B2" as total_amount

Reads a single cell value by sheet and cell reference.

Read PDF text "contract.pdf" as contract_text
Read DOCX text "agreement.docx" as agreement_text

Extracts plain text content from document files.

Write report to "tmp/report.txt"
Overwrite summary to "tmp/summary.txt"

Write saves text. Overwrite explicitly replaces existing content.

Export results to "tmp/results.json"
Export rows to "tmp/output.csv" as CSV

Export serializes records and lists as pretty JSON by default. Use as CSV to write a list of records as a CSV table.

Append "processed\n" to file "tmp/run.log"

Adds text to the end of an existing file without replacing content.

Copy file from "/inbox/receipt.pdf" to "/receipts/2026-07/receipt.pdf"
Move file from "/tmp/draft.txt" to "/archive/final.txt"

Both create parent directories automatically. Copy supports directories (recursive).

Create directory "/receipts/2026-07/"
Delete file "/tmp/scratch.txt"

Delete file removes files or directories recursively.

Check if "/inbox/receipt.pdf" exists as file_found
If file_found:
Print "File is present"

Stores true or false.

Get file info for "/inbox/receipt.pdf" as info
Print size of info
Print type of info

Returns a record with path, type (“file”, “directory”, or “symlink”), size (bytes), and modified (Unix timestamp).

List files in "/inbox/" as entries
Find files matching "*.pdf" in "/inbox/" as pdf_files
For each file in pdf_files:
Print file

List files returns sorted filenames. Find files matching uses glob patterns and returns full paths.

Wrap file operations in Try blocks for graceful recovery:

Try:
Read JSON from "maybe-missing.json" as data
Otherwise:
data equals record with "default" as mode
Print last_error