Dead simple standard for storing/loading datasets as lines of text. Supports zstd compression.
Project description
Lines Dataset
Dead simple standard for storing/loading datasets as lines of text. Supports zstd compression.
pip install lines-dataset
Format
A dataset folder looks like this:
my-dataset/
meta.json
my-inputs.txt
my-compressed-labels.txt.zst
other-labels.txt.zst
...
meta.json
:
{
"lines_dataset": {
"inputs": {
"file": "my-inputs.txt",
"num_lines": 3000 // optionally specify the number of lines
},
"labels": {
"file": "my-compressed-labels.txt.zst",
"compression": "zstd",
"num_lines": 3000
},
"other-labels": {
"file": "other-labels.txt.zst",
"compression": "zstd",
"num_lines": 2000 // not all files need to have the same number of lines, as long as samples match line by line. The shortest file will determine the length of the dataset.
},
},
// you can add other stuff if you want to
}
Usage
import lines_dataset as lds
ds = lds.Dataset.read('path/to/my-dataset')
num_samples = ds.len('inputs', 'labels') # int | None
for x in ds.samples('inputs', 'labels'):
x['inputs'] # "the first line of inputs.txt\n"
x['labels'] # "the decompressed first line of labels.txt.zst\n"
A common convenience to use is:
import lines_dataset as lds
datasets = lds.glob('path/to/datasets/*') # list[lds.Dataset]
for x in lds.chain(datasets, 'inputs', 'labels'):
...
And that's it! Simple.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lines_dataset-0.2.8.tar.gz
(4.3 kB
view hashes)
Built Distribution
Close
Hashes for lines_dataset-0.2.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e3607031732b37647ddf12452ae69fa336bde237506584599645a191f1b5918 |
|
MD5 | 452539095218e4549e05eb03318fdd51 |
|
BLAKE2b-256 | 348a41e4e12afdc07a4de3d15534b1c382eba45712eb864df053dee7901912e2 |