Import std.data.csv
std.data.csv
Csv: comma-separated values, as RFC 4180 has them: rows of fields, each line a row and its fields between separators, a field in '"'s when it holds the separator, a '"', or a line break, with its '"'s doubled. Lines end with LF, CRLF, or a CR alone, and the last needn't end. A separator other than ',', like ';' or a tab, can be given.
std/data/csv.fb
Types
Csv
struct
Public Struct Csv
What reads and writes comma-separated values, in its Static Methods.
-
@PanicsAtCaller Public Static Method Read(text: String, separator: String = ","): String[][] Throws ParseErrorstatic method #The rows
textholds, each its fields, an empty line a row of one empty field. Throws a ParseError, with its line and column, of UNEXPECTED_END for a quoted field that doesn't end, and of SYNTAX for a '"' in a field that isn't quoted or after one that ends. Panics when theseparatorisn't one ASCII character other than '"' or a line break. -
@PanicsAtCaller Public Static Method ReadRecords(text: String, separator: String = ","): Value Throws ParseErrorstatic method #The records
textholds: its first row is a header of names, and each row after it an Object of its fields by those names, as Strings, in an Array. Throws a ParseError as Read does, and of SYNTAX for a header that names a field twice, or a row with more or fewer fields than it. -
@PanicsAtCaller Public Static Method Write(rows: String[][], separator: String = ","): Stringstatic method #rowsas CSV, each on its line, ended with LF, a field quoted when it holds theseparator, a '"', or a line break, starts or ends with a space, or starts with a byte order mark. Panics when theseparatorisn't one ASCII character other than '"' or a line break, or a row has no fields, which CSV can't hold: an empty line is a row of one empty field. -
@PanicsAtCaller Public Static Method WriteRecords(records: Value, separator: String = ","): Stringstatic method #records, an Array of Objects, as CSV, with a header of every key they have, in the order they come in, and a row for each, a key it hasn't got an empty field: a String as it is, a Bool, an integer, or a Double as its text, and Null as nothing. Panics whenrecordsisn't an Array of Objects, a field is an Array or an Object, therecordshave no keys, or theseparatoris one Write panics for. No records are no text.
Report an issue with this page or with FutureBlitz on GitHub.