-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
csv2rec imports dates incorrectly and has no option #208
Comments
I'm the original poster of this issue at sourceforge. Perhaps an option to set the "dayfirst" and "yearfirst" parameters of the datetime library without touching the current interface would be fine. |
Hi, I've just been hit by this bug, and it's actually worse than described. |
What would be better, in my opinion, is for |
csv2rec is built around using dateutil.parser for handling dates, and that in turn is designed to be dangerous; if a date is invalid for one convention, another convention is tried, until something fits, or it fails completely. It doesn't tell you what convention it ended up using, it just returns the result. The simplest way to improve csv2rec would be to let it pass precedence kwargs to dateutil.parser. I think the only way to go beyond that would be to allow one to specify that only a single convention, given as a strptime format, would be tried, thereby allowing one to bypass all the dateutil flexibility. |
Closing; #1210 was merged. |
Original report at SourceForge, opened Mon Jun 6 05:36:16 2011
when using the csv2rec, you have no option to specify the date format previous to importing, which means ambiguous dates tend to get wrong according to the format.
For example, in a csv file with the date
12-01-1998
The default for mlib is to import in the MM-DD-YY format - which result in december, 1st, 1998.
However, the next line,
13-01-1998
dateutil correctly identifies as unambiguous and parses it as jan 13th, 1998.
The library dateutil that mlib uses has ways to specify date precedence, as seen here: http://labix.org/python-dateutil#head-b95ce2094d189a89f80f5ae52a05b4ab7b41af47
But there's no way to specify date precedence in mlib.
The text was updated successfully, but these errors were encountered: