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 24, 2019 · 11 revisions

Global Functions

Function Name Description
add_item(key,value,dictionary) Adds value to the List corresponding to key
get_com_pro(col) Returns a String depending on if "Product", "Commodity", or neither are present in col
get_prefix(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): Returns a Setup object with __slots__=[file]

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
make_config_path() Creates a new folder "config" if not present in current working directory
write_config(type) Writes a json file based on given DataFrame

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 json-based dictionary

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 decoded json object

Clone this wiki locally