SchemaLoaderDF

class SchemaLoaderDF(filenames, schema_as_strings_or_df, name='')[source]

Load dataframe schemas from filenames

Expected usage is SchemaLoaderDF.load(filenames)

Note: due to supporting multiple files, this one differs from the other schema loaders

Methods

SchemaLoaderDF.__init__(filenames, ...[, name])

Loads the given schema from one of the two parameters.

SchemaLoaderDF.find_rooted_entry(tag_entry, ...)

This semi-validates rooted tags, raising an exception on major errors

SchemaLoaderDF.load([filename, ...])

Loads and returns the schema, including partnered schema if applicable.

SchemaLoaderDF.load_spreadsheet([filenames, ...])

Loads and returns the schema, including partnered schema if applicable.

Attributes

SchemaLoaderDF.schema

The partially loaded schema if you are after just header attributes.

SchemaLoaderDF.__init__(filenames, schema_as_strings_or_df, name='')[source]

Loads the given schema from one of the two parameters.

Parameters:
  • filename (str or None) – A valid filepath or None

  • schema_as_string (str or None) – A full schema as text or None

  • schema (HedSchema or None) – A HED schema to merge this new file into It must be a with-standard schema with the same value.

  • file_format (str or None) – The format of this file if needed(only for owl currently)

  • name (str or None) – Optional user supplied identifier, by default uses filename

static SchemaLoaderDF.find_rooted_entry(tag_entry, schema, loading_merged)

This semi-validates rooted tags, raising an exception on major errors

Parameters:
  • tag_entry (HedTagEntry) – the possibly rooted tag

  • schema (HedSchema) – The schema being loaded

  • loading_merged (bool) – If this schema was already merged before loading

Returns:

The base tag entry from the standard schema

Returns None if this tag isn’t rooted

Return type:

rooted_tag(HedTagEntry or None)

Raises:

HedFileError

  • A rooted attribute is found in a non-paired schema

  • A rooted attribute is not a string

  • A rooted attribute was found on a non-root node in an unmerged schema.

  • A rooted attribute is found on a root node in a merged schema.

  • A rooted attribute indicates a tag that doesn’t exist in the base schema.

classmethod SchemaLoaderDF.load(filename=None, schema_as_string=None, schema=None, file_format=None, name='')

Loads and returns the schema, including partnered schema if applicable.

Parameters:
  • filename (str or None) – A valid filepath or None

  • schema_as_string (str or None) – A full schema as text or None

  • schema (HedSchema or None) – A HED schema to merge this new file into It must be a with-standard schema with the same value.

  • file_format (str or None) – If this is an owl file being loaded, this is the format. Allowed values include: turtle, json-ld, and owl(xml)

  • name (str or None) – Optional user supplied identifier, by default uses filename

Returns:

The new schema

Return type:

schema(HedSchema)

classmethod SchemaLoaderDF.load_spreadsheet(filenames=None, schema_as_strings_or_df=None, name='')[source]

Loads and returns the schema, including partnered schema if applicable.

Parameters:
  • filenames (str or None or dict of str) – A valid set of schema spreadsheet filenames If a single filename string, assumes the standard filename suffixes.

  • schema_as_strings_or_df (None or dict of str) – A valid set of schema spreadsheet files(tsv as strings)

  • name (str) – what to identify this schema as

Returns:

The new schema

Return type:

schema(HedSchema)

SchemaLoaderDF.schema

The partially loaded schema if you are after just header attributes.