class CSVDatasetImporter(foud.GenericSampleDatasetImporter, foud.ImportPathsMixin): (source)
Constructor: CSVDatasetImporter(dataset_dir, data_path, labels_path, media_field, ...)
A flexible CSV importer that represents slice(s) of field values of a dataset as columns of a CSV file.
See :ref:`this page <CSVDataset-import>` for format details.
Parameters | |
dataset | the dataset directory. If omitted, data_path and/or labels_path must be provided |
data | an optional parameter that enables explicit control over the location of the media. Can be any of the following:
If None, this parameter will default to whichever of data/ or data.json exists in the dataset directory |
labels | an optional parameter that enables explicit control over the location of the labels. Can be any of the following:
If None, the parameter will default to labels.csv |
media | the name of the column containing the media path for each sample. The media paths in this column may be:
|
fields | an optional parameter that specifies the columns to read and parse from the CSV file. Can be any of the following:
If not provided, all columns are parsed as strings |
skip | whether to skip (True) or raise an error (False) when rows with no media_field are encountered |
include | whether to generate samples for all media in the data directory (True) rather than only creating samples for media with CSV rows (False) |
shuffle | whether to randomly shuffle the order in which the samples are imported |
seed | a random seed to use when shuffling |
max | a maximum number of samples to import. By default, all samples are imported |
Method | __init__ |
Undocumented |
Method | __iter__ |
Undocumented |
Method | __len__ |
The total number of samples that will be imported. |
Method | __next__ |
Returns information about the next sample in the dataset. |
Method | setup |
Performs any necessary setup before importing the first sample in the dataset. |
Instance Variable | data |
Undocumented |
Instance Variable | fields |
Undocumented |
Instance Variable | include |
Undocumented |
Instance Variable | labels |
Undocumented |
Instance Variable | media |
Undocumented |
Instance Variable | skip |
Undocumented |
Property | has |
Whether this importer produces a dataset info dictionary. |
Property | has |
Whether this importer produces a sample field schema. |
Instance Variable | _fields |
Undocumented |
Instance Variable | _filepaths |
Undocumented |
Instance Variable | _iter |
Undocumented |
Instance Variable | _media |
Undocumented |
Instance Variable | _num |
Undocumented |
Instance Variable | _rows |
Undocumented |
Inherited from GenericSampleDatasetImporter
:
Method | get |
Returns a dictionary describing the field schema of the samples loaded by this importer. |
Inherited from DatasetImporter
(via GenericSampleDatasetImporter
):
Method | __enter__ |
Undocumented |
Method | __exit__ |
Undocumented |
Method | close |
Performs any necessary actions after the last sample has been imported. |
Method | get |
Returns the dataset info for the dataset. |
Method | _preprocess |
Internal utility that preprocesses the given list---which is presumed to be a list defining the samples that should be imported---by applying the values of the shuffle, seed, and max_samples parameters of the importer. |
Inherited from ImportPathsMixin
(via GenericSampleDatasetImporter
, DatasetImporter
):
Static Method | _load |
Helper function that parses either a data directory or a data manifest file into a UUID -> filepath map. |
Static Method | _parse |
Helper function that computes default values for the data_path parameter supported by many importers. |
Static Method | _parse |
Helper function that computes default values for the labels_path parameter supported by many importers. |
Undocumented
Returns information about the next sample in the dataset.
Returns | |
a fiftyone.core.sample.Sample instance | |
Raises | |
StopIteration | if there are no more samples to import |
Performs any necessary setup before importing the first sample in the dataset.
This method is called when the importer's context manager interface is
entered, DatasetImporter.__enter__
.