specless.dataset.CSVDataset
- class specless.dataset.CSVDataset(filedir: str, filepaths: List[str] | None = None)[source]
Bases:
BaseDataset
Reads a list of csv files and turns them into a dataset.
Users can either provide a directory to the traces or a list of filepaths.
Examples
Provide a directory to the traces:
>>> filedir = '/path/to/the/csv/directory/' >>> dataset = CSVDataset(filedir)
If the user strictly needs a sorted dataset, they can provide a list of paths:
>>> filedir = '/path/to/the/csv/directory/' >>> filepaths = [os.path.join(filedir, str(i)) for i in range(100)] >>> dataset = CSVDataset(filedir, filepaths=filepaths)
Methods
Apply a function to each item in the data.
Convert the data to a list.
Attributes
Get the length of the data.
- apply(func: Callable[[...], Any]) None
Apply a function to each item in the data.
- Parameters:
func (Callable[..., Any]) – The function to apply to each item.
- property length: int
Get the length of the data.
- Returns:
The length of the data.
- Return type:
int
- tolist(key: str | None = None)
Convert the data to a list.
- Parameters:
key (Optional[str], default=None) – The key to use to convert the data to a list. If None, all data is converted.
- Returns:
The data converted to a list.
- Return type:
list