Skip to content
This repository was archived by the owner on Mar 28, 2025. It is now read-only.

formatcheck.py documentation

echang97 edited this page Jul 2, 2019 · 11 revisions

Global Functions

Function Name Description
add_item(key,value,dictionary) Adds value to the Set corresponding to key
get_com_pro(col) Returns a String depending on if "Product", "Commodity" or both are present in col
get_data_type(name) Returns a String determined by keywords in name
split_unit(string) Returns a List, splitting Item and Unit

Class: Setup

Dependencies: Pandas

Keyword Arguments:
    file -- A Pandas DataFrame
    type -- Prefix for the config file, derived from sample file name

Constuctor

class Setup(file=None): Returns a Setup object and sets its variables based on the given DataFrame

Methods

Method Name Description
get_header(file) Returns a List of Columns based on given DataFrame
get_unit_dict(file) Returns a Dictionary mapping of Items and Units
get_misc_cols(file) Returns a Dictionary mapping of Fields and Expected Values
set_file(file) Sets variables based on given DataFrame
write_config(type) Pickles the Setup object and writes itself into a bin file

Class: FormatChecker

Dependencies: Pandas

Keyword Arguments:
    file -- A Pandas DataFrame
    type -- Prefix for the config file, derived from sample file name

Constuctor

class FormatChecker(type): Returns a FormatChecker with a Setup object based on type

Methods

Method Name Description
get_w_count(file) Returns number of W's found for Volume and Location
check_header(file) Checks header for Order and missing or unexpected field names
check_misc_cols(file) Checks non-numerical columns for Unexpected Values
check_nan(file) Checks if specific columns are missing values
check_unit_dict(file) Checks commodities/products for New items or Unexpected units of measurement
read_config(type) Returns an unpickled Setup object

(WIP) Class: NumberChecker

Dependencies: Pandas

Keyword Arguements:
    file -- A Pandas DataFrame
    sd -- Number of Standard Deviations

Methods

Method Name Description
check_sd(file, sd) Goes through Rev/Vol and prints out values outside of SD
check_threshold(file, min, max) Goes through Rev/Vol and prints out values outside of range (min-max)

Clone this wiki locally