Module Delimited

module Delimited: sig .. end
Parsers for delimited 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; (*
The field separator character. (Default ',')
*)
   record_sep : char; (*
The record separator character. (Default '\n')
*)
   trim_space : bool; (*
Whether to remove whitespace from the beginning and end of each field. (Default true)
*)
   rec_backslash : bool; (*
A backslash quotes the next character. (Default false)
*)
   rec_quotation : bool; (*
Recognize double quotes. (Default true)
*)
   rec_double_double : bool; (*
Within quotation marks, two double quotes in a row denote one double quote. (Default true)
*)
   rec_cr : bool; (*
Treat a carriage return that precedes a record separator as part of the separator. This, along with setting the record separator to '\n', will treat MS-DOS CRLF as a record separator.
*)
   rec_escapes : bool; (*
Recognize backslash sequences such as "\\n" for newline and "\\t" for tab.
*)
   max_fields : int; (*
The maximum number of fields to split into. Field separators and fields subsequent to this are all concatenated in the last field. A value of 0 (the default) means unlimited.
*)
}
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 -> Reader.t
The CSV reader. Splits a file into raw lines, 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 raw line content, 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_line : ?options:options -> Pervasives.out_channel -> string array -> unit
Output a CSV line, including the newline.