skbio.io.read

skbio.io.read(fp, format=None, into=None, verify=True, mode='U', **kwargs)[source]

Read a supported skbio file format into an instance or a generator.

This function is able to reference and execute all registered read operations in skbio.

Parameters:

fp : filepath or filehandle

The location to read the given format into. Filepaths are automatically closed when read; filehandles are the responsibility of the caller. In the case of a generator, a filepath will be closed when StopIteration is raised; filehandles are still the responsibility of the caller.

format : str, optional

The format must be a format name with a reader for the given into class. If a format is not provided or is None, all registered sniffers for the provied into class will be evaluated to attempt to guess the format. Default is None.

into : type, optional

A class which has a registered reader for a given format. If into is not provided or is None, read will return a generator. Default is None.

verify : bool, optional

Whether or not to confirm the format of a file if format is provided. Will raise a skbio.io.FormatIdentificationWarning if the sniffer of format returns False. Default is True.

mode : str, optional

The read mode. This is passed to open(fp, mode) internally. Default is ‘U’

kwargs : dict, optional

Will be passed directly to the appropriate reader.

Returns:

object or generator

If into is not None, an instance of the into class will be provided with internal state consistent with the provided file. If into is None, a generator will be returned.

Raises:

ValueError

Raised when format and into are both None.

skbio.io.UnrecognizedFormatError

Raised when a reader could not be found for a given format or the format could not be guessed.

skbio.io.FormatIdentificationWarning

Raised when verify is True and the sniffer of a format provided a kwarg value that did not match the user’s kwarg value.