blob: b0be69095e82235d424150c7c1903198a968f2e4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
(** During the test, we don’t care with the file existence *)
let context =
ImportConf.
{ loadFile = (fun _ -> Otoml.array []); checkFile = (fun _ -> true) }
let load' :
?dataset:(string -> Otoml.t) ->
string ->
(ImporterSyntax.t, string) Result.t =
fun ?(dataset = fun _ -> Otoml.array []) content ->
let toml = Otoml.Parser.from_string content in
ImportConf.t_of_toml toml ~context:{ context with loadFile = dataset }
let load_from_file :
?dataset:(string -> Otoml.t) ->
string ->
(ImporterSyntax.t, string) Result.t =
fun ?(dataset = fun _ -> Otoml.array []) content ->
let toml = Otoml.Parser.from_file content in
ImportConf.t_of_toml toml ~context:{ context with loadFile = dataset }
(** Read the configuration in toml and return the internal representation *)
let load : string -> ImporterSyntax.t =
fun content -> Result.get_ok (load' content)
let conf =
load
{|[source]
file = "source.xlsx"
name = "source"
[externals.other]
intern_key = ":A"
file = "other.xlsx"
extern_key = ":C"
allow_missing = false
[externals.last_file]
intern_key = ":other.A"
file = "last.xlsx"
extern_key = ":C"
allow_missing = true
[sheet]
columns = [
":A ^ '_'",
":B",
":last_file.E",
]|}
let external_table_source =
ImportDataTypes.Table.{ file = "source.xlsx"; tab = 1; name = "source" }
let external_table_other =
ImportDataTypes.Table.{ file = "other.xlsx"; tab = 1; name = "other" }
let external_other =
ImporterSyntax.Extern.
{
intern_key = Path { alias = None; column = 1 };
target = external_table_other;
extern_key = Path 3;
allow_missing = false;
filters = [];
}
let external_table_last =
ImportDataTypes.Table.{ file = "last.xlsx"; tab = 1; name = "last_file" }
let external_last =
ImporterSyntax.Extern.
{
intern_key = Path { alias = Some "other"; column = 1 };
target = external_table_last;
extern_key = Path 3;
allow_missing = true;
filters = [];
}
|