11-csv-textok
Structure
importcsv:lib/csv.mq.mdtext:lib/text.mq.md
fn · h1CSV cleaning with text helpers
comment
fn · h1main
bind
`raw` = name,city
Ada,london
Bob,PARIS
bind
`rows` = > csv.parse text=`raw`bind
`r0` = > at value=`rows` index=0bind
`city` = > text.to_upper text=[city](`r0`)call
> print text=[name](`r0`)call
> print text=`city`bind
`n` = > len `rows`branch
arm
`n` == 2call
> print text=mid-m4-okarm
elsecall
> print text=mid-m4-failFunctions
Variables
-
city textLONDONLONDON
-
n int22
-
r0 map · 2
name Ada city london key value name Ada city london -
raw textname,city Ada,london Bob,PARISname,city Ada,london Bob,PARIS
-
rows list · 2
# name city 1 Ada london 2 Bob PARIS # name city 1 Ada london 2 Bob PARIS
Execution
Ada
LONDON
mid-m4-ok
Source
--- title: Mid stdlib — csv and text description: lib/csv + thickened lib/text (Mid M4) import csv:lib/csv.mq.md import text:lib/text.mq.md --- # CSV cleaning with text helpers Parse a tiny CSV, normalize a field, print — no plugins. # main **raw = "name,city\nAda,london\nBob,PARIS\n"** **rows = > csv.parse text=`raw`** **r0 = > at value=`rows` index=0** **city = > text.to_upper text=[city](`r0`)** > print text=[name](`r0`) > print text=`city` **n = > len `rows`** 1. `n` == 2 > print text=mid-m4-ok 2. * > print text=mid-m4-fail
Parse a tiny CSV, normalize a field, print — no plugins.