Closed horva closed 9 years ago
@horva have you tried updating dateparser? Seems to be working fine for me.
In [8]: DateDataParser().get_date_data('22nd July 2012')
Out[8]: {'date_obj': datetime.datetime(2012, 7, 22, 0, 0), 'period': 'day'}
@horva Please check that your dateutil
version is up to date with one in requirements.txt
Thanks @Allactaga updating dateutil fixed it.
I just installed dateparser module from master repo and can reproduce the bug with:
from dateparser.date import DateDataParser DateDataParser().get_date_data('22nd July 2012')
I found out about the bug with a script like this:
record = "19 de Junio de 2006" d = dateparser.parse(unicode(record))
Hi @garaged, seems to be working fine for me. Like advised above, please check your dateutil
version in requirements.txt
.
In [1]: from dateparser.date import DateDataParser
In [2]: DateDataParser().get_date_data('22nd July 2012')
Out[2]: {'date_obj': datetime.datetime(2012, 7, 22, 0, 0), 'period': u'day'}
In [3]: record = "19 de Junio de 2006"
In [4]: import dateparser
In [5]: dateparser.parse(unicode(record))
Out[5]: datetime.datetime(2006, 6, 19, 0, 0)
you are right, it works
I missed the fact that I should check dateutil version, I missread it as dateparser, so I knew I had the latest from git, but after your comment I took a look aht the requirements.txt file, and I had dateutil 2.2, after update to 2.4.x it worked as expected.
Thanks a lot !! Max
Seems to be broken (again). My packages are up-to-date:
(env)~/D/Amazon-Review-Scraper ❯❯❯ pip freeze
...
dateparser==0.3.3
...
python-dateutil==2.5.0
...
But I get the same error:
(env)~/D/Amazon-Review-Scraper ❯❯❯ python
Python 2.7.11 (default, Dec 26 2015, 17:47:53)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import dateparser
>>> dateparser.parse('22nd July 2012')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/chris/Documents/Amazon-Review-Scraper/env/lib/python2.7/site-packages/dateparser/conf.py", line 80, in wrapper
return f(*args, **kwargs)
File "/Users/chris/Documents/Amazon-Review-Scraper/env/lib/python2.7/site-packages/dateparser/__init__.py", line 40, in parse
data = parser.get_date_data(date_string, date_formats)
File "/Users/chris/Documents/Amazon-Review-Scraper/env/lib/python2.7/site-packages/dateparser/date.py", line 343, in get_date_data
language, date_string, date_formats, settings=self._settings)
File "/Users/chris/Documents/Amazon-Review-Scraper/env/lib/python2.7/site-packages/dateparser/date.py", line 161, in parse
return instance._parse()
File "/Users/chris/Documents/Amazon-Review-Scraper/env/lib/python2.7/site-packages/dateparser/date.py", line 171, in _parse
date_obj = parser()
File "/Users/chris/Documents/Amazon-Review-Scraper/env/lib/python2.7/site-packages/dateparser/date.py", line 189, in _try_dateutil_parser
self._get_translated_date(), settings=self._settings)
File "/Users/chris/Documents/Amazon-Review-Scraper/env/lib/python2.7/site-packages/dateparser/conf.py", line 80, in wrapper
return f(*args, **kwargs)
File "/Users/chris/Documents/Amazon-Review-Scraper/env/lib/python2.7/site-packages/dateparser/date_parser.py", line 180, in parse
date_obj, period = dateutil_parse(date_string, settings=settings)
File "/Users/chris/Documents/Amazon-Review-Scraper/env/lib/python2.7/site-packages/dateparser/date_parser.py", line 163, in dateutil_parse
return new_parser().parse(date_string, settings=settings, **kwargs)
File "/Users/chris/Documents/Amazon-Review-Scraper/env/lib/python2.7/site-packages/dateparser/date_parser.py", line 40, in parse
new_date = self._populate(res, default, settings=settings)
File "/Users/chris/Documents/Amazon-Review-Scraper/env/lib/python2.7/site-packages/dateparser/date_parser.py", line 68, in _populate
value = getattr(res, field)
AttributeError: 'tuple' object has no attribute 'year'
Hi @inkrement the error is because of python-dateutil version 2.5.0. Downgrading python dateutil to 2.4.2 should fix this.
Reporting error:
AttributeError: 'tuple' object has no attribute 'year'
Which can be reproduced with:
Issue is present since merge of https://github.com/scrapinghub/dateparser/pull/50/files