Osy#betaRun it on Osyrin: osyrin.com

Kits · Data

CSV

CSV in and out — quoted fields, Excel's separators and byte-order mark, formula-safe cells.

Package
Osysharp.Csv
Install
use Osysharp.Csv@0;
Group
Data
Tests
5 in the kit’s own suite
Builds on
—
Used by
Shop, Mailing lists, Reports — build them, share them

Spreadsheets in and out of an Osy# app — the product list a shop owner edits in Excel, the subscriber list they export, the stock count they paste back.

osy

use Osysharp.Csv@0;          // in app.osy

var text  = WriteCsv(["SKU", "Name", "Price"], [["GG-1", "Kiambu AA, washed", "165"]]);
var table = ReadCsv(uploadedText);
foreach (var row in table.Rows) {
  var sku = table.Get(row, "SKU");            // by column name — case and spaces ignored
}

What it gets right so the file "just opens":

  • A UTF-8 byte-order mark, so Excel reads Göteborg as Göteborg.
  • CRLF and RFC 4180 quoting — a field is quoted only when it holds the separator, a quote or a line break.
  • The separator is detected when reading: a Swedish or German Excel saves ; (the comma is their decimal point), and a paste out of a spreadsheet is tab-separated.
  • No cell runs as a formula. A value starting =, +, - or @ is written with a leading ' (CSV injection — =HYPERLINK(…) in a customer's name), and reading takes it off again. A number such as -5 is left alone.
  • Row line numbers (row.Line), so an import can say which line it refused.

Get it

Add the kit to your app’s manifest:

osy

app MyApp {
  use Osysharp.Csv@0;
}

Then run osy lock: it downloads the release, verifies it by its content address and pins that version in osyrin.lock. osy kits Osysharp.Csv shows what the kit is for, from inside your app.