aboutsummaryrefslogtreecommitdiff
path: root/lib/file_handler/xlsx2sql.ml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/file_handler/xlsx2sql.ml')
-rw-r--r--lib/file_handler/xlsx2sql.ml44
1 files changed, 23 insertions, 21 deletions
diff --git a/lib/file_handler/xlsx2sql.ml b/lib/file_handler/xlsx2sql.ml
index f2d8f12..651059f 100644
--- a/lib/file_handler/xlsx2sql.ml
+++ b/lib/file_handler/xlsx2sql.ml
@@ -1,8 +1,6 @@
open StdLabels
module A = ImportAnalyser.Dependency
module C = ImportContainers
-module CSV = ImportCSV
-module Syntax = ImportConf.Syntax
module Db = ImportSQL.Db
let flags = Unix.[ O_RDONLY; O_NONBLOCK ]
@@ -10,24 +8,26 @@ let flags = Unix.[ O_RDONLY; O_NONBLOCK ]
let extractors =
SZXX.Xlsx.
{
- string = (fun _location s -> CSV.DataType.Content s);
+ string = (fun _location s -> ImportDataTypes.Value.Content s);
error =
- (fun _location s -> CSV.DataType.Error (Printf.sprintf "#ERROR# %s" s));
+ (fun _location s ->
+ ImportDataTypes.Value.Error (Printf.sprintf "#ERROR# %s" s));
boolean =
(fun _location s ->
let value = String.(equal s "1") in
- CSV.DataType.Content (string_of_bool value));
+ ImportDataTypes.Value.Content (string_of_bool value));
number =
(fun _location s ->
let f = Float.of_string s in
- if Float.is_integer f then CSV.DataType.Integer (Float.to_int f)
- else CSV.DataType.Float f);
- date = (fun _location s -> CSV.DataType.Content s);
- null = CSV.DataType.Null;
+ if Float.is_integer f then
+ ImportDataTypes.Value.Integer (Float.to_int f)
+ else ImportDataTypes.Value.Float f);
+ date = (fun _location s -> ImportDataTypes.Value.Content s);
+ null = ImportDataTypes.Value.Null;
formula =
(fun _location ~formula s ->
ignore formula;
- CSV.DataType.Content s);
+ ImportDataTypes.Value.Content s);
}
let feed_bigstring ic =
@@ -48,29 +48,31 @@ let is_delayed row =
| _ -> false)
let default_mapper :
- (ImportCSV.DataType.t, ImportCSV.DataType.t SZXX.Xlsx.row) State.mapper =
+ ( ImportDataTypes.Value.t,
+ ImportDataTypes.Value.t SZXX.Xlsx.row )
+ State.mapper =
{
get_value =
(function
- | ImportCSV.DataType.Content s ->
- ImportCSV.DataType.Content (SZXX.Xml.unescape s)
+ | ImportDataTypes.Value.Content s ->
+ ImportDataTypes.Value.Content (SZXX.Xml.unescape s)
| any -> any);
- default = ImportCSV.DataType.Null;
+ default = ImportDataTypes.Value.Null;
get_row = (fun v -> v.SZXX.Xlsx.data);
}
-type state = CSV.DataType.t SZXX.Xlsx.status SZXX.Xlsx.row State.t
+type state = ImportDataTypes.Value.t SZXX.Xlsx.status SZXX.Xlsx.row State.t
let delayed_mapper =
State.
{
get_value =
(function
- | SZXX.Xlsx.Available (CSV.DataType.Content s) ->
- CSV.DataType.Content (SZXX.Xml.unescape s)
+ | SZXX.Xlsx.Available (ImportDataTypes.Value.Content s) ->
+ ImportDataTypes.Value.Content (SZXX.Xml.unescape s)
| SZXX.Xlsx.Available value -> value
- | _ -> CSV.DataType.Null);
- default = SZXX.Xlsx.Available CSV.DataType.Null;
+ | _ -> ImportDataTypes.Value.Null);
+ default = SZXX.Xlsx.Available ImportDataTypes.Value.Null;
get_row = (fun v -> v.SZXX.Xlsx.data);
}
@@ -96,11 +98,11 @@ let first_row : A.t -> _ Db.t -> state -> 'a SZXX.Xlsx.row -> state =
let importInDatable :
log_error:Csv.out_channel Lazy.t ->
- conf:Syntax.t ->
+ conf:ImporterSyntax.t ->
dirname:string ->
A.t ->
'a Db.t ->
- CSV.DataType.t array option Lwt.t =
+ ImportDataTypes.Value.t array option Lwt.t =
fun ~log_error ~conf ~dirname mapping db ->
let file = Filename.concat dirname (A.table mapping).file in