Unable to import CSV

45 views
Skip to first unread message

Carlos Sánchez de La Lama

unread,
Apr 10, 2023, 7:29:07 AM4/10/23
to ledge...@googlegroups.com
Hi all,

I am trying to follow the steps in the manual
(https://ledger-cli.org/doc/ledger3.html#The-convert-command) to
import CSV data into my journal. But I am getting different errors.

I have reduced my test case to a simple almost empty journal:

2022/12/01 * Opening Balance
Assets:MyBank 3117.82
Equity:Opening Balances

And a simple CSV taken from the examples in the manual:

,date,payee,note,debit,credit,balance,code,
767406,12/13/2022,"Deposit","CASH DEPOSIT",,45.00,00001646.89,,
767718,12/13/2022,"Withdrawal","ACE HARDWARE 16335 S HOUGHTON
RD",8.80,,00001640.04,,

But I am getting an error:
LANG=C ~/src/ledger/ledger convert test.csv --input-date-format
"%m/%d/%Y" --invert --account Assets:MyBank --rich-data --file
test.dat --now=2023/01/13

While parsing file "test.csv", line 1:
While parsing CSV line:
767406,12/13/2022,"Deposit","CASH DEPOSIT",,45.00,00001646.89,,

Error: Cannot negate an uninitialized amount
Without the --invert flag, the error changes:

Error: Only one posting with null amount allowed per transaction

What am I doing wrong?

Thanks,

Carlos

Carlos Sánchez de La Lama

unread,
Apr 11, 2023, 12:10:26 PM4/11/23
to ledge...@googlegroups.com
I found the reason. I was following the last version of the manual,
which has "credit" and "debit" fields in CVS parser. But I am using
ledger-3.1.3, which had "amount" field only. I see src/cvs.h changed
in newer versions.

My problem is fixed. Hopefully this helps someone else with the same problem :)

BR

Carlos

El lun, 10 abr 2023 a las 13:28, Carlos Sánchez de La Lama
(<csanc...@gmail.com>) escribió:
Reply all
Reply to author
Forward
0 new messages