spmviz.io.read_spmf#

spmviz.io.read_spmf(path, name=None)[source]#

Read a sequence database in SPMF format.

Items are integers separated by spaces, -1 closes an itemset, -2 a sequence. Supported extensions: @ITEM=<code>=<label> lines (labels), <t> timestamps before an itemset, item[utility] annotations and a trailing SUtility: field (dropped), comment lines (#, %, @).

Examples

>>> import io, tempfile, pathlib
>>> p = pathlib.Path(tempfile.mkdtemp()) / "db.txt"
>>> _ = p.write_text("1 -1 1 2 3 -1 -2\n2 -1 3 -1 -2\n")
>>> read_spmf(p)[0]
((1,), (1, 2, 3))