Otter
Snippets
Otter
Upstream Otter 1.0.1 Tested
Parse CSV Text Into Structured Rows
Convert delimiter-separated text data into an array of typed property records.
Architecture & Runtime Preview
Otter 1.0.1Zero-dependency Otter 1.0.1 snippet (Files & Storage). Copy the parameterized template or run the self-contained example.
- 1Category: Files & Storage
- 2Attribution: Otter Core Language Spec (D95)
- 3Zero external pack dependencies — paste directly into any .ot file
Source Code (2 files)
convert ${csvText} from csv into ${rows}
for each ${row} in ${rows}
say ${row}
.
csvContent is "name,department,level\nAlice,Engineering,4\nBob,Design,3"
convert csvContent from csv into staff
say "Staff count:" length of staff
if length of staff is not 2
fail with "csv parse staff count mismatch: expected 2"
.
firstMember is first of staff
if name of firstMember is not "Alice"
fail with "csv parse first member name mismatch: expected Alice"
.
if department of firstMember is not "Engineering"
fail with "csv parse first member department mismatch: expected Engineering"
.
Installation & Usage
otter snippet inspect file-csv-parse
Copy template.ot directly into your .ot source file, or run example.ot with 'otter run example.ot'.