datapad.io.read_text#
- datapad.io.read_text(path_or_paths, lines=True)#
Construct a Sequence from text files
- Parameters:
path_or_paths – str or list of strings A path, or list of paths. Paths may contain glob patterns like “data/metadata-*-a.txt”
lines – bool (default: True) If True, each element of the sequence comes from reading a line in the text file. If False, each element in sequence comes from the entire text file.
>>> seq = read_text(["data/meta-*.txt"], lines=True) >>> seq.collect() ["foo_a", "foo_b", "bar_a", "bar_b"]
>>> seq = read_text(["data/meta-*.txt"], lines=False) >>> seq.collect() ["foo_a\nfoo_b", "bar_a\nbar_b"]