Text_File_Handler module

file_to_table

procedure · 1 overloadSource

Like file_to_array, but returns the lines as the keys of a table, so repeated lines are kept once. The second result is the table. The caller frees each key and the table (deinit from Hash_Table). On a failure it is false and an empty table.

file_to_table :: (
    filename: string,
    do_trim := true,
    skip_blank_lines := true,
    do_version_number := false,
    use_data_from_memory := false,
    data_from_memory := "",
    loc := #caller_location
) -> (success: bool, table: T.Table(string, void))

Parameters

filename: string
do_trim := true
skip_blank_lines := true
do_version_number := false
use_data_from_memory := false
data_from_memory := ""
loc := #caller_location

Returns

success: bool
table: T.Table(string, void)
ExampleOpen in playground ↗
ok, table := file_to_table("set.txt", use_data_from_memory = true, data_from_memory = "x\ny\nx\n");
assert(ok && table.count == 2);

See also