print_readable/save_out_readable changed:
[ocaml-csv.git] / csv.mli
diff --git a/csv.mli b/csv.mli
index d4d8cd9..baf9e5c 100644 (file)
--- a/csv.mli
+++ b/csv.mli
@@ -1,13 +1,13 @@
 (** csv.mli - comma separated values parser
   *
-  * $Id: csv.mli,v 1.4 2005-02-17 15:51:47 rich Exp $
+  * $Id: csv.mli,v 1.7 2005-11-25 14:08:46 rich Exp $
   *)
 
 type t = string list list
 (** Representation of CSV files. *)
 
 exception Bad_CSV_file of string
-(** Badly formed CSV files throw this exception: *)
+(** Badly formed CSV files throw this exception. *)
 
 val lines : t -> int
 (** Work out the number of lines in a CSV file. *)
@@ -69,7 +69,47 @@ val square : t -> t
 (** Make the CSV data "square" (actually rectangular).  This pads out
   * each row with empty cells so that all rows are the same length as
   * the longest row.  After this operation, every row will have length
-  * {!columns}.
+  * {!Csv.columns}.
+  *)
+
+val is_square : t -> bool
+(** Return true iff the CSV is "square" (actually rectangular).  This
+  * means that each row has the same number of cells.
+  *)
+
+val set_columns : int -> t -> t
+(** [set_columns cols csv] makes the CSV data square by forcing the width
+  * to the given number of [cols].  Any short rows are padded with blank
+  * cells.  Any long rows are truncated.
+  *)
+
+val set_rows : int -> t -> t
+(** [set_rows rows csv] makes the CSV data have exactly [rows] rows
+  * by adding empty rows or truncating rows as necessary.
+  *
+  * Note that [set_rows] does not make the CSV square.  If you want it
+  * to be square, call either {!Csv.square} or {!Csv.set_columns} after.
+  *)
+
+val set_size : int -> int -> t -> t
+(** [set_size rows cols csv] makes the CSV data square by forcing the
+  * size to [rows * cols], adding blank cells or truncating as necessary.
+  * It is the same as calling [set_columns cols (set_rows rows csv)]
+  *)
+
+val sub : int -> int -> int -> int -> t -> t
+(** [sub r c rows cols csv] returns a subset of [csv].  The subset is
+  * defined as having top left corner at row [r], column [c] (counting
+  * from [0]) and being [rows] deep and [cols] wide.
+  *
+  * The returned CSV will be square.
+  *)
+
+val to_array : t -> string array array
+val of_array : string array array -> t
+(** Convenience functions to convert to and from a matrix representation.
+  * [to_array] will produce a ragged matrix (not all rows will have the
+  * same length) unless you call {!Csv.square} first.
   *)
 
 val associate : string list -> t -> (string * string) list list
@@ -93,7 +133,7 @@ val associate : string list -> t -> (string * string) list list
   *     etc. ]
   * v}
   *
-  * Each row is turned into an assoc list (see {!List.assoc}).
+  * Each row is turned into an assoc list (see [List.assoc]).
   *
   * If a row is too short, it is padded with empty cells ([""]).  If
   * a row is too long, it is truncated.
@@ -121,9 +161,10 @@ val save : ?separator:char -> string -> t -> unit
 val print_readable : t -> unit
 (** Print the CSV data to [stdout] in a human-readable format.  Not much
   * is guaranteed about how the CSV is printed, except that it will be
-  * easier to follow than a "raw" output done with {!print}.  This is
+  * easier to follow than a "raw" output done with {!Csv.print}.  This is
   * a one-way operation.  There is no easy way to parse the output of
   * this command back into CSV data.
   *)
 val save_out_readable : out_channel -> t -> unit
-(** As for {!print_readable}, allowing the output to be sent to a channel. *)
+(** As for {!Csv.print_readable}, allowing the output to be sent to a channel.
+  *)