Documentation
¶
Overview ¶
Package csv is the "encoding/csv" host module. See std/encoding/register.go for why this and its eight siblings each get their own leaf package instead of living in std's flat root, and how this directory's Module reaches the rest of magus without std importing back down to collect it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Module = std.Module{ Name: "csv", WASM: true, Path: "encoding/csv", Doc: "Delimiter-separated tabular text (CSV, TSV) parsing and rendering.", Methods: []std.Method{ { Name: "parse", Doc: "Parse delimiter-separated text into a list of rows, each a list of fields. Quoted fields, embedded delimiters, and embedded newlines are handled per RFC 4180. delimiter defaults to \",\" - pass \"\\t\" for TSV. When comment is a single character, lines starting with it are skipped. Raises when a row has a different field count than the first, which is the corruption a hand-rolled split would silently pass through.", Args: []std.Arg{ {Name: "s", Type: std.TypeString}, {Name: "delimiter", Type: std.TypeString, Optional: true, Default: ","}, {Name: "comment", Type: std.TypeString, Optional: true}, }, Returns: []std.Ret{{Type: std.TypeStringSliceSlice}}, Raises: true, Impl: CSVParse, }, { Name: "stringify", Doc: "Render rows (a list of lists of fields) as delimiter-separated text, quoting any field that needs it. delimiter defaults to \",\". The output ends with a newline, so it is ready to write.", Args: []std.Arg{ {Name: "rows", Type: std.TypeStringSliceSlice}, {Name: "delimiter", Type: std.TypeString, Optional: true, Default: ","}, }, Returns: []std.Ret{{Type: std.TypeString}}, Raises: true, Impl: CSVStringify, }, }, }
Module is the "encoding/csv" host module: delimiter-separated tabular text, in and out. Nothing in Buzz or in magus could read a table before this - a magusfile handed a coverage export, a dependency inventory, or any tool's --format=csv output had to split on commas by hand, which is wrong the moment a field is quoted or contains the delimiter.
TSV is this module with delimiter set to a tab rather than a separate module: the format differs by one character and nothing else, so a second name would be two things to learn for one behavior.
The options are ORDINARY OPTIONAL ARGUMENTS, not an opts map. Most of the stdlib's older methods take {str: any} bags, which means a misspelled key is silent; a declared argument is checked. New surface should not add to that.
Functions ¶
func CSVStringify ¶
CSVStringify renders rows as delimiter-separated text.
Types ¶
This section is empty.