Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: can't compare offset-naive and offset-aware datetimes #66

Open
niconoe opened this issue Feb 28, 2020 · 1 comment
Open

TypeError: can't compare offset-naive and offset-aware datetimes #66

niconoe opened this issue Feb 28, 2020 · 1 comment
Assignees
Labels

Comments

@niconoe
Copy link
Contributor

niconoe commented Feb 28, 2020

  • pywhip version: 0.3.3
  • Python version: 3.7
  • Operating System: Mac OS

Description

Traceback:

$ python mytest.py
mytest.py:5: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  specifications = yaml.load(whip_specs_file)
Traceback (most recent call last):
  File "mytest.py", line 8, in <module>
    specifications, delimiter='\t')
  File "/Users/nicolas_noe/miniconda3/envs/tmp-feb28/lib/python3.7/site-packages/pywhip/pywhip.py", line 86, in whip_csv
    field_names, maxentries)
  File "/Users/nicolas_noe/miniconda3/envs/tmp-feb28/lib/python3.7/site-packages/pywhip/pywhip.py", line 347, in _whip
    self.validation.validate(row)  # apply specification rules
  File "/Users/nicolas_noe/miniconda3/envs/tmp-feb28/lib/python3.7/site-packages/cerberus/validator.py", line 877, in validate
    self.__validate_definitions(definitions, field)
  File "/Users/nicolas_noe/miniconda3/envs/tmp-feb28/lib/python3.7/site-packages/cerberus/validator.py", line 940, in __validate_definitions
    result = validate_rule(rule)
  File "/Users/nicolas_noe/miniconda3/envs/tmp-feb28/lib/python3.7/site-packages/cerberus/validator.py", line 922, in validate_rule
    return validator(definitions.get(rule, None), field, value)
  File "/Users/nicolas_noe/miniconda3/envs/tmp-feb28/lib/python3.7/site-packages/pywhip/validators.py", line 314, in _validate_mindate
    if event_date < min_date:
TypeError: can't compare offset-naive and offset-aware datetimes

What I Did

Ran:

import yaml
from pywhip import whip_csv

with open("specs.yaml") as whip_specs_file:
    specifications = yaml.load(whip_specs_file)

    observations_whip = whip_csv("occurrence.txt", 
                             specifications, delimiter='\t')
    with open("report_observations.html", "w") as index_page:
        index_page.write(observations_whip.get_report('html'))

With:

country:
   allowed: [BE, NL]
eventDate:
    dateformat: '%Y-%m-%d'
    mindate: 2016-01-01
    maxdate: 2018-12-31
individualCount:
    numberformat: x  # needs to be an integer value
    min: 1
    max: 100
@niconoe niconoe added the bug label Feb 28, 2020
@niconoe niconoe self-assigned this Feb 28, 2020
@niconoe
Copy link
Contributor Author

niconoe commented Feb 28, 2020

Data file:
occurrence.txt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant