skbio.io.sniff

skbio.io.sniff(fp, cls=None, mode='U')[source]

Attempt to guess the format of a file and return format str and kwargs.

Parameters:

fp : filepath or filehandle

The provided file to guess the format of. Filepaths are automatically closed; filehandles are the responsibility of the caller.

cls : type, optional

A provided class that restricts the search for the format. Only formats which have a registered reader or writer for the given cls will be tested. Default is None.

Returns:

(str, kwargs)

A format name and kwargs for the corresponding reader.

Raises:

UnrecognizedFormatError

This occurs when the format is not ‘claimed’ by any registered sniffer or when the format is ambiguous and has been ‘claimed’ by more than one sniffer.