We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 39adf3c + ba84fa0 commit c01d75fCopy full SHA for c01d75f
1 file changed
README.md
@@ -70,6 +70,17 @@ m = Map.from_iter(items, path="/tmp/map.fst")
70
matches = dict(m['clarence':])
71
assert matches == {'clarence': 2, 'stevie': 3}
72
73
+# Create a map from a file input, using generators/yield
74
+# The input file must be sorted on the first column, and look roughly like
75
+# keyA 123
76
+# keyB 456
77
+def file_iterator(fpath):
78
+ with open(fpath, 'rt') as fp:
79
+ for line in fp:
80
+ key, value = line.strip().split()
81
+ yield key, int(value)
82
+m = Map.from_iter( file_iterator('/your/input/file/'), '/your/mmapped/output.fst')
83
+
84
# re-open a file you built previously with from_iter()
85
m = Map(path='/path/to/existing.fst')
86
```
0 commit comments