Utilities

Helper modules and shared functionality.

Columns

Column mapping and data structure utilities.

Extracts column information from a file and provides utilities for working with columns in a web form.

hedweb.columns.create_column_selections(form_dict) tuple[list[str], list[str]][source]

Return a tag prefix dictionary from a form dictionary.

Parameters:

form_dict (dict) – The column prefix table returned from a form.

Returns:

list of value columns and a list of skipped columns.

Return type:

tuple[list[str], list[str]]

hedweb.columns.get_tag_columns(form_dict) list[str][source]

Return the tag column names selected from a form.

Parameters:

form_dict (dict) – The column names table.

Returns:

List of tag columns

Return type:

list[str]

hedweb.columns.dataframe_from_worksheet(worksheet, has_column_names) DataFrame[source]

Return a pandas data frame from an Excel worksheet.

Parameters:
  • worksheet (Worksheet) – A single worksheet of an Excel file.

  • has_column_names (bool) – If True, interpret the first row as column names.

Returns:

The data represented in the worksheet.

Return type:

DataFrame

hedweb.columns.get_columns_request(request) dict[source]

Create a columns info dictionary based on the request.

Parameters:

request (Request) – The Request object from which to extract the information.

Returns:

The dictionary with the column names.

Return type:

dict

Raises:

HedFileError – If the file is missing or has a bad extension.

hedweb.columns.get_column_numbers(form_dict) list[source]

Return a tag prefix dictionary from a form dictionary.

Parameters:

form_dict (dict) – The dictionary returned from a form that contains a column table.

Returns:

List of selected columns.

Return type:

list

Note: The form counts columns starting from 1.