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
Release history Release notifications | RSS feed
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
Close
Hashes for info_check_toolkits-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f47a94208e1d1aa0beb69c2b244eace523831ccc73e9dfa651b1f2fa081ccd3 |
|
MD5 | 1ee18436454233fbe4ded424eb3ecb62 |
|
BLAKE2b-256 | 4bd535f38ead316a8cfdc9ee78b3bc94853e3c3ffc8954e7f270ee2db31db8af |