From 6b377719c10d5ab3343fd5221f99a4a21008e25a Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Thu, 14 Mar 2024 08:26:58 +0100 Subject: Initial commit --- lib/csv/dataType.ml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/csv/dataType.ml (limited to 'lib/csv/dataType.ml') diff --git a/lib/csv/dataType.ml b/lib/csv/dataType.ml new file mode 100644 index 0000000..c582b9c --- /dev/null +++ b/lib/csv/dataType.ml @@ -0,0 +1,21 @@ +let match_date = Re.Str.regexp {|[0-9]+/[0-9]+/[0-9]+|} + +type t = + | Null + | Error of string + | Content of string + | Integer of int + | Float of float + +let to_string = function + | Null -> "" + | Error s -> s + | Integer i -> string_of_int i + | Float f -> string_of_float f + | Content c -> ( + match String.starts_with ~prefix:"0" c with + | false -> c + | true -> + (* If the string is a date, do not escape it *) + if Re.Str.string_match match_date c 0 then c + else String.concat "" [ "=\""; c; "\"" ]) -- cgit v1.2.3