All examples
Data

Typed data from a CSV to a Tensor

Declare a schema, summarize the supplied visits fixture, inspect typed columns and materialize complete numeric features.

data_basics.aner
// The included visits.csv fixture has six synthetic records, not patient data.
// Run from the directory that contains examples/fixtures/visits.csv.
import aner.data
import aner.tensor

var schema = data.schema()
schema = data.column(schema, "record_id", "String", false)
schema = data.column(schema, "age", "Int64", true)
schema = data.column(schema, "measurement", "Float64", true)
schema = data.column(schema, "site", "String", false)
schema = data.column(schema, "eligible", "Bool", false)
let source = data.scan_csv("examples/fixtures/visits.csv", schema, missing: "NA")
let adults = data.where_ge(source, "age", value: 18)
let selected = data.include(data.select(adults, "measurement"), "age")
let report = data.summarize(selected, max_bytes: 1048576, batch_rows: 2)
print("Validated, selected, present and missing measurement counts")
print(data.scanned_rows(report))
print(data.rows(report))
print(data.valid(report, "measurement"))
print(data.missing(report, "measurement"))
print("Mean of present measurements")
print(data.mean(report, "measurement"))
let table = data.collect(data.where_present(selected, "measurement"),
    max_rows: 100, max_bytes: 1048576, batch_rows: 2)
print("Collected schema")
print(data.column_name(table, 0))
print(data.column_type(table, 0))
print(data.column_nullable(table, 0))
let values = data.to_tensor(table, max_bytes: 1048576)
print("Complete numeric tensor shape and first measurement")
print(tensor.rows(values))
print(tensor.cols(values))
print(tensor.value(values, 0, 0))

Make it your experiment.

With Aner installed, save this program as examples/data_basics.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.

Terminal
aner check examples/data_basics.aner
aner run examples/data_basics.aner

The aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.

Use a compatible installed native Aner executable. Save the supplied fixture as examples/fixtures/visits.csv, preserving the relative directory structure, and run from the containing project folder.

Bundled datasets retain their own source attribution and license notices. Example outcomes are not comparative benchmarks or evidence of clinical validity.

Dataset sources & attribution
Install Aner