Problems with multiple date_format variants in a single CSV
archont00 opened this issue · 2 comments
Hi,
I am struggling with date_format. My bank uses:
date_format = "%d.%m.%Y %H:%M"
date_format_user = "%d.%m.%Y"
This used to work until recently as follows:
StatementLine = super(SampleParser, self).parse_record(line)
StatementLine.date_user = datetime.strptime(StatementLine.date_user, self.date_format_user)
But not anymore - the parser (python 3.8) does not consider the date field as string anymore and tries to parse the date_user before I can do so (and fails due to a wrong format_date).
Any help?
Hi @archont00,
Do I understand the issue correctly? It worked previously because the date would be parsed with the wrong format without the error by super().parse_record()
and you would just re-parse it later with the right format?
If so, I'd recommend you to remove date_user
from your mappings
, so these fields would not be converted automatically by super().pare_record(line)
, and just do the conversion from string yourself in your overridden parse_record()
.