### Navigation

- index
- modules |
- CCHR 1.0 documentation »

# `Segment`

This module is used to work with the CCHR segment files (initial data files).

Exported Classes:

Exported Methods:

Exceptions:

ConvertError

class `src.segment.``Segment`(segment, phase, **opt)

  Segment object contains various methods to load, manipulate and save CCHR segment data files.

  Public Methods:

  load_vars – Loads the CCHR variable set as defined in the metadata.

  get_index – Takes a variable name and returns its index.

  load_data – Loads the segment data.

  convert_vars – Converts the types of all the variables to match the metadata file

  get_data – Returns the loaded dataset or None

  add_new_vars – Adds derived standardized varaibles to the dataset.

  set_length_rules – Sets length rules on all variables in the ds based on metadata file.

  find_var_lengths – Determines longest length for the original varaible in
    the dataset and updates the metadata file with this information.

  assign_var_lengths – Assigns length rules to all the variables.

  get_max_length – Returns the highest varaible length in the dataset.

  save – Saves the dataset.

  `add_new_vars`()

    Add new variables

  `convert_vars`()
  `create_recid_table`()
  `drop_vars`(format)
  `get_index`(name, original=False)

    Return the variable index of a supplied variable.

    Arguments: name – The name of the variable who’s index we want to find. original – Set to True to return the original index

  `get_max_length`()

    Return the highest variable length in the dataset.

  `get_metadata`(name)

    Import json metadata

  `get_rules`()

    Get the rules.

  `load_data`()

    Load the segment data.

    If loading delimited data this is assumed to be the original segment data so it is loading using the original variable names. If in_filter was included as an option then will apply the filter variable function.

    If limit was included in the options then will limit the rows loaded based on the limit value.

  `load_metadata_variables`()

    Load variable information from the metadata file.

    The variable information in the metadata file contains the full variable set for the segment. This method creates a variable set of the original variable names and stores this in the orig_var_names property.

  `load_processed_data`(as_cache=False)
  `load_raw_data`()
  `load_staged_data`()
  `save`()

    Save the dataset.

    Supported Keywords:

  `set_rules`()

    Assigns rules to the variables associated with cardsharp dataset stored on self.ds. This is not used during process command because we assign the rules during the data_load.

  `update_metadata_var_lengths`()

    Set the length variable information for the original variables.

`src.``segment`

  alias of `src.segment`

### Navigation

- index
- modules |
- CCHR 1.0 documentation »