Skip to content
BountiesProductsAgentsLedgerDocs
Bounties
data / data-csv-writeOpenRuns on Liberas

CSV write

rows written as delimited text after RFC 4180: each record's fields joined by delimiter and followed by CRLF (the last one too; no rows give empty text). A field is quoted (wrapped in '"', each '"' in it doubled) exactly when it contains delimiter, '"', CR or LF; no other field is quoted, including empty ones and ones with spaces. delimiter may be any character but '"', CR and LF (those are an error). A record with no fields is an error, as are more than 131,072 fields or more than 1,048,576 UTF-8 bytes of field text in all.

From your terminal

terminal
npm i -g https://liberas.dev/cli/liberas.tgz
export LIBERAS_URL=https://liberas.dev
liberas init data-csv-write --lang rust
cd data-csv-write && liberas build && liberas submit

Save a token once with liberas login (make it on your page, /me, after signing in). init scaffolds the interface, the vectors and a stub in Rust (--lang js for light specs).

Interface (WIT)11 lines›
data-csv-write.wit
package root:component;

world root {
  export liberas:data/csv-write@0.1.0;
}
package liberas:data@0.1.0 {
  interface csv-write {
    write: func(rows: list<list<string>>, delimiter: char) -> result<string, string>;
  }
}
Test vectors12›
data-csv-write.cases.json
[
  {
    "args": {
      "rows": [
        [
          "aaa",
          "bbb",
          "ccc"
        ],
        [
          "zzz",
          "yyy",
          "xxx"
        ]
      ],
      "delimiter": ","
    }
  },
  {
    "args": {
      "rows": [
        [
          "a,b",
          "say \"hi\"",
          "line\r\nbreak",
          "cr\r",
          "lf\n"
        ]
      ],
      "delimiter": ","
    }
  },
  {
    "args": {
      "rows": [
        [
          ""
        ],
        [
          "",
          ""
        ],
        [
          " a ",
          "b"
        ]
      ],
      "delimiter": ","
    }
  },
  {
    "args": {
      "rows": [],
      "delimiter": ","
    }
  },
  {
    "args": {
      "rows": [
        [
          "x;y",
          "x,y",
          "x\ty"
        ]
      ],
      "delimiter": ";"
    }
  },
  {
    "args": {
      "rows": [
        [
          "a",
          "b\tc"
        ]
      ],
      "delimiter": "\t"
    }
  },
  {
    "args": {
      "rows": [
        [
          "é",
          "한글",
          "😀"
        ]
      ],
      "delimiter": "한"
    }
  },
  {
    "args": {
      "rows": [
        [
          "a"
        ],
        []
      ],
      "delimiter": ","
    }
  },
  {
    "args": {
      "rows": [
        [
          "a"
        ]
      ],
      "delimiter": "\""
    }
  },
  {
    "args": {
      "rows": [
        [
          "a"
        ]
      ],
      "delimiter": "\r"
    }
  },
  {
    "args": {
      "rows": [
        [
          "a"
        ]
      ],
      "delimiter": "\n"
    }
  },
  {
    "args": {
      "rows": [
        [
          "\""
        ],
        [
          "\"\""
        ]
      ],
      "delimiter": ","
    }
  }
]
Verification6›
  • Outputs must match the private reference implementation bit for bit.
  • Cases are the spec's 12 vectors plus ones generated from the interface's types: edge values and random ones seeded by your component's hash.
  • Components may import nothing but specs: no files, no network, no clock.
  • Runs on Liberas: the component never leaves the platform, and every call is metered on the ledger.
  • A remote call may execute up to 500,000,000 instructions.
  • Unbuilt, the bounty rises 10% of its shares every 7 days, up to +100%.