hi-dateinfer
Python library to infer date format from examples. This is an actively maintained fork of the original dateinfer library by Jeffery Starr. It maintains python 2/3 compatibility and will be released as hi-dateinfer. Pull requests and issues welcome.
Table of Contents
Problem Statement
Imagine that you are given a large collection of documents and, as part of the extraction process, extract date information and store it in a normalized format. If the documents follow a single schema, the ideal approach is to craft a date parsing string for the schema. However, if the documents follow different schemas or if the contents are noisy (e.g. date fields were hand-populated), the development can become onerous.
This library makes a "best guess" on the proper date parsing string (datetime.strptime) based on examples in
the file.
Installation
git clone https://github.com/hi-primus/hi-dateinfer.git
cd dateinfer
pip install .
or
pip install hi-dateinfer
Usage
>>> import dateinfer
>>> dateinfer.infer(['Mon Jan 13 09:52:52 MST 2014', 'Tue Jan 21 15:30:00 EST 2014'])
'%a %b %d %H:%M:%S %Z %Y'
>>>
Give dateinfer.infer a list of example date strings. infer returns a datetime.strftime/strptime-compliant
date format string for its "best guess" of a format string that will correctly parse the majority of the examples.
Development
Use the following to install the package locally for development purposes:
# create empty virtual environment
virtualenv venv --python=python3.7
source venv/bin/activate
# install dateinfer in editable mode
pip install -e .
# install development dependencies
pip install -r requirements.txt
You can run unit tests as follows:
python -m unittest dateinfer/tests.py
Metadata
Release files for hi-dateinfer 0.4.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hi-dateinfer-0.4.6.tar.gz | 18.5 kB | Without provenance | Details for hi-dateinfer-0.4.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hi_dateinfer-0.4.6-py3-none-any.whl | Python 3 | none | any | Details for hi_dateinfer-0.4.6-py3-none-any.whl |
Total release size: 36.2 kB
Release files / hi-dateinfer-0.4.6.tar.gz
| Download URL | hi-dateinfer-0.4.6.tar.gz |
|---|---|
| Size | 18.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e2ded27aeb15ee6fcda0a30c2a341acbdaaa5b95c1c4db4c4680a4dbcda35c54
|
|
BLAKE2b-256 checksum How to use checksums |
3e73447b4f9019909e9d94c67a9892b75d52df29850887cefa06d194ce6615ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7
|
Release files / hi_dateinfer-0.4.6-py3-none-any.whl
| Download URL | hi_dateinfer-0.4.6-py3-none-any.whl |
|---|---|
| Size | 17.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
46d27ccc875890315eec9d71d76c2306e84388c4a88106d2f768a921debb49e8
|
|
BLAKE2b-256 checksum How to use checksums |
13c7868b174e83cf03ffa8ad4cb70d121278f5691abed1ade1b19485de869e3e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.7
|
Security for hi-dateinfer 0.4.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.