-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathCSV.tla
36 lines (28 loc) · 1.07 KB
/
CSV.tla
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
-------------------------------- MODULE CSV --------------------------------
LOCAL INSTANCE TLC
LOCAL INSTANCE Integers
(*************************************************************************)
(* Imports the definitions from the modules, but doesn't export them. *)
(*************************************************************************)
CSVWrite(template, val, file) ==
(*
CSVWrite("%1$s#%2$s#%3$s",
<<"abc", 42, {"x", "y"} >>, "/tmp/out.csv")
*)
TRUE
CSVWriteRecord(record, delim, headers, file) ==
(*
CSVWriteRecord([foo |-> 42] @@ [bar |-> "frob"],
CSVRecords("/tmp/out.csv") = 0, "#", "/tmp/out.csv")
*)
TRUE
CSVRead(columns, delimiter, file) ==
(*
CSVRead(<<"C1", "C2", "C3">>, "#", "/tmp/out.csv")
<< [ C1 |-> "\"abc\"", C2 |-> "42", C3 |-> "{"\"x\"", "\"y\""}" ] >>
*)
TRUE
CSVRecords(file) ==
(* The number of records in the given file (including headers if any). *)
CHOOSE n : n \in Nat
============================================================================