Skip to main content

a set of toolkits for checking a dictionary with String values

Project description

Info Check Toolkits

Check a dictionary with String values

Probelms

Contains the result of the check

  • problem_type: empty value or invalid value
  • column: which column do the problem occur
  • msg: detail about the problem

Limits

Currently support four limits

  • num_limit(int): a certain limit of the length of the value
  • no_space(bool): control whether space can be used in value
  • is_date(bool): control whether the value has a format of YYYYMMDD
  • value_range(List): a list of value in which value can be choosen

Default options

  • num_limit: 0 (no limit)
  • no_space: True (space can't be used)
  • is_date: False
  • value_range: [] (no limit)

Processor

Attributes

  • columns: a list of the columns of the dictionary
  • limits: a dictionary from columns to Limit objects, store options for each column

Method

  • check_row(row): check given dictionary with given limits, return a list of problems or None

Usage

Code

from info_check_toolkits.toolkits import *

columns = ['name', 'age', 'sex']
limits = [
    Limit(num_limit=4),
    Limit(value_range=[str(i) for i in range(100)]),
    Limit(num_limit=1, value_range=('M', 'F'))
]

processor = Processor(columns, limits)

row = {'name': 'alice', 'age': '18', 'sex': 'm'}
result = processor.check_row(row)
if result is not None:
    for problem in result:
        print(problem.msg)

Output

name is more than 4
sex is out of range

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

info_check_toolkits-0.0.6-py3-none-any.whl (4.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page