Charles.Forsyth20061220965a0ca19 years agoHistory
58 lines · 1.6 KB · Text
RawDownload
.TH CSV 2.SH NAMEcsv \- comma-separated values.SH SYNOPSIS.EXinclude "bufio.m";include "csv.m";csv := load CSV CSV->PATH; init:    fn(bufio: Bufio);getline: fn(fd: ref Bufio->Iobuf): list of string;quote:   fn(s: string): string;.EE.SH DESCRIPTION.B CSVprovides a few functions to help read and write data in ``comma-separated value'' format.The.I csvformat has a sequence of fields on a line (terminated by a newline, carriage return,or carriage return and newline).Fields are separated by commas, and may be empty.A field that starts with a double-quote is a quoted field, continuingto the next lone double-quote character, including commas and line terminators,but taking two double-quotes to represent one double-quote.Any text following quoted text, up to the next comma or line terminator, is includedin the field value.Note that in a field that does not start with a double-quote, double-quotes are not treated specially..PP.B Initmust be called before any other operation of the module..I Bufiois the instance of the.IR bufio (2)module that will provide the open files to be read..PP.B Getlinereads a sequence of fields in.I csvformat from.B Iobuf.IR fd ,unquotes fields as required, and returns them in order in a list.It returns nil on end-of-file (or read error).An empty line is regarded as containing a single empty field..PP.B Quotereturns string.I squoted as required by the.I csvformat:the result is quoted if.I scontains comma, newline, or a quote (and all embedded quotes are doubled)..SH SOURCE.B /appl/lib/csv.b.SH SEE ALSO.IR sh-csv (1)