load

emtellipro.load

This module contains all the code necessary for loading input documents from files or database.

The documents loaded by this module are intended to be submitted to emtelliPro.

Also see emtellipro.ccd for reading CCD files.

Submodules

  • data - LoadedFile from various sources.
  • utils - These are utility functions helpful for loading files.

Module Contents

Functions

NameDescription
readfileRead documents from the given file path.

API

emtellipro.load.readfile

emtellipro.load.readfile(
path: typing.Union[str, pathlib.Path],
filetype = None,
**kwargs
) -> emtellipro.load.data.LoadedFile

Read documents from the given file path.

This function is used for loading documents from files which will then be submitted to emtelliPro for processing (using emtellipro.engine.Emtellipro).

Although CCDs are readable using this function, for more control over how they’re parsed, see emtellipro.ccd.

For more details on the supported file formats, see /input-formats

Parameters:

path
typing.Union[str, pathlib.Path]

The path to the file. May be a string of pathlib.Path instance.

filetype

The filetype to use for the given file; this is used to override the automatic detection based on file extensions.

**kwargs

Extra arguments to pass to the file handler for the given/detected filetype.

These may include:

category The default category to use; may be overriden by the value specified in the file in the case of JSON files. If emtelliPro should infer the category, this should be set to “auto”.

This should be set.

subcategory The default subcategory to use; may be overriden by the value specified in the file in the case of JSON files.

This should be set.

section_label The section label value to use when submitting a document to emtelliPro. This is optional.

file_encoding For text files, it’s important to know the file encoding if it’s not utf-8, because the autodetection of file encoding may be slow or get it wrong.

doc_id_filepath Whether to generate a document ID based on the file path; this is mostly helpful for debugging errors.

config An extra config dictionary that is currently only used by the CCD plugin. It should have a mapping where the key is ‘ccd’ and the value is a dictionary with any extra CCD-related options.

See the CCD section of the documentation for more details.

Returns:

The loaded file containing the input documents. Example:

# can be passed in to override the automatic detection.
loaded_file = readfile('path/to/file.txt', '.ccd')
print(loaded_file.docs)
print(loaded_file.docs[0].text)

Return type: LoadedFile