aboutsummaryrefslogtreecommitdiff
path: root/lib/csv/dataType.ml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/csv/dataType.ml')
-rw-r--r--lib/csv/dataType.ml21
1 files changed, 21 insertions, 0 deletions
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; "\"" ])