You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I miss a way to define date format for date2 for cases when date and date2 fields use different format, I miss command date2-format to define format of date for field date2
date is 31.12.2023 00:00:00, date-format is %d.%m.%Y 00:00:00 or %d.%m.%Y %X (%X is time)... date2 is 31.12.2023, date-format should be %d.%m.%Y
In this example, date and date2 are the same and date2 could be ignored but I see there is no way to import date2 field when date and date2 use different format of date...
$ hledger --version
hledger 1.32.3, linux-x86_64
$ hledger -f test-date2.csv print
hledger: Error: error: could not parse "31.12.2023" as a date using date format "%d.%m.%Y 00:00:00"
CSV record: "1","31.12.2023 00:00:00","Interest","","31.12.2023","","","","","330,52","",""
the date2 rule is: %f5
the date-format is: %d.%m.%Y 00:00:00
you may need to change your date2 rule, change your date-format rule, or add a skip rule
for m/d/y or d/m/y dates, use date-format %-m/%-d/%Y or date-format %-d/%-m/%Y
I have found a workaround with if block - hledger 1.32+ required.
Anyway, I believe that date2-format should be added, it makes parsing easier...
WORKAROUND; note I have to define date field, it is mandatory; I see this as a bug:
$ cat test-date2w.csv.rules
separator ;
fields f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12
date-format %Y-%m-%d
code %f1
#date %f2
#date2 %f5
description %f3
amount %f10
# default date; date is mandatory; it will be rewritten or an error will be reported when parsing of date fails...
date 9999-99-99
# debug
comment \n%f1;%f2;%f3;%f4;%f5;%f6;%f7;%f8;%f9;%f10;%f11;%f12
# skip header
if %f1 #
skip
# parse date
if %f2 (.+)\.(.+)\.(....)
date \3-\2-\1
# parse date2
if %f5 (.+)\.(.+)\.(....)
date2 \3-\2-\1
If support for multiple date formats in a record is needed, I'd prefer not to tie it to the date2 (secondary date) feature. That's both too limiting and would invest more time in a feature which shouldn't exist.
simonmichael
added
A-WISH
Some kind of improvement request, hare-brained proposal, or plea.
csv
The csv file format, csv output format, or generally CSV-related.
labels
May 12, 2024
I miss a way to define date format for
date2
for cases whendate
anddate2
fields use different format, I miss commanddate2-format
to define format of date for fielddate2
Example:
date
is31.12.2023 00:00:00
, date-format is%d.%m.%Y 00:00:00
or%d.%m.%Y %X
(%X is time)...date2
is31.12.2023
, date-format should be%d.%m.%Y
In this example,
date
anddate2
are the same anddate2
could be ignored but I see there is no way to importdate2
field whendate
anddate2
use different format of date...DEMO:
hledger
doesn't like format ofdate2
:I have found a workaround with
if block
- hledger 1.32+ required.Anyway, I believe that
date2-format
should be added, it makes parsing easier...WORKAROUND; note I have to define
date
field, it is mandatory; I see this as a bug:Test it:
The text was updated successfully, but these errors were encountered: