module Delimited: sig
.. end
Parsers for delmited text formats, especially CSV. This module
provides a record reader, field splitter, and printer.
The delimiter, quoting, and whitespace behavior are all
configurable.
type
options = {
|
field_sep : char ; |
|
record_sep : char ; |
|
trim_space : bool ; |
|
rec_backslash : bool ; |
|
rec_quotation : bool ; |
|
rec_double_double : bool ; |
|
rec_cr : bool ; |
|
rec_escapes : bool ; |
|
max_fields : int ; |
}
Options for parsing delimited text files.
val default_options : options
The default options. To read records with the default options but
also recognizing backslash, one might write
Csv.reader ~options:{default_options with recognize_backslash = true}
.
val reader : ?options:options -> Pervasives.in_channel -> Reader.raw_line
The CSV reader. Splits a file into records, but doesn't interpret
any quoting; that is, you get out what you put in.
val splitter : ?options:options -> string -> string array
The CSV splitter. Given a single CSV record, splits it into
fields and interprets quoting and escaping properly to recover
the original strings.
val output_field : ?options:options -> Pervasives.out_channel -> string -> unit
Output a single field, escaped as necessary for CSV.
val output_record : ?options:options -> Pervasives.out_channel -> string array -> unit
Output a CSV record, including the newline.