marqdo

11-csv-textok

features/11-csv-text.mq.md

Structure

importcsv:lib/csv.mq.mdtext:lib/text.mq.md
fn · h1CSV cleaning with text helpers
comment

Parse a tiny CSV, normalize a field, print — no plugins.

fn · h1main
bind `raw` = name,city Ada,london Bob,PARIS
bind `rows` = > csv.parse text=`raw`
bind `r0` = > at value=`rows` index=0
bind `city` = > text.to_upper text=[city](`r0`)
call> print text=[name](`r0`)
call> print text=`city`
bind `n` = > len `rows`
branch
arm`n` == 2
call> print text=mid-m4-ok
armelse
call> print text=mid-m4-fail
Functions
Variables
  • city text
    LONDON
  • n int
    2
  • r0 map · 2
    nameAda
    citylondon
  • raw text
    name,city Ada,london Bob,PARIS
  • rows list · 2
    #namecity
    1Adalondon
    2BobPARIS

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

Variable