-
-
Notifications
You must be signed in to change notification settings - Fork 121
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Exceptions are normal expected behavior when typecasting an invalid format. However, r.parsedate() is really just re-formatting strings and keeping the type as text. So it may be better to print-and-pass on exception so the user can see a complete list of invalid values -- while also allowing for the parser to reformat the remaining valid values.
sqlite-utils convert idfpr.db license "Expiration Date" "r.parsedate(value)"
[#######-----------------------------] 21% 00:01:57Traceback (most recent call last):
File "/usr/local/lib/python3.9/dist-packages/sqlite_utils/db.py", line 2336, in convert_value
return fn(v)
File "<string>", line 2, in fn
File "/usr/local/lib/python3.9/dist-packages/sqlite_utils/recipes.py", line 8, in parsedate
parser.parse(value, dayfirst=dayfirst, yearfirst=yearfirst).date().isoformat()
File "/usr/lib/python3/dist-packages/dateutil/parser/_parser.py", line 1374, in parse
return DEFAULTPARSER.parse(timestr, **kwargs)
File "/usr/lib/python3/dist-packages/dateutil/parser/_parser.py", line 652, in parse
raise ParserError("String does not contain a date: %s", timestr)
dateutil.parser._parser.ParserError: String does not contain a date: / /
In this case, I had just one variation of an invalid date: ' / / '. But theoretically there could be many values that would have to be fixed one at a time with the current exception handling.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request