Hi,
I've exported my Amazon transactions into a `CSV` file using the `Amazon
Order History Reporter` extension. The file looks like this:
```
order id,order date,quantity,description,price
300-1000000-1000000,2022-10-26,1,"Foo","19.99"
300-1000000-2000000,2022-11-18,1,"bar","39.95"
```
I came up with this config file:
```
from beancount.ingest.importers.csv import Importer as CSVImporter, Col
my_amazon_csv_importer = CSVImporter({
Col.DATE: 'order date',
Col.NARRATION1: 'description',
Col.AMOUNT: 'price'
},
'Expenses:Amazon', # account
'EUR', # currency
# regexps used by ImporterProtocol.identify() to
identify the correct file
#('order id,order date,quantity,description,price'
#),
skip_lines=0
)
CONFIG = [my_amazon_csv_importer]
```
to extract the transactions with:
```
bean-extract config_amazon_csv.py amazon_order_history_2022.csv
```
But this fails with:
```
ERROR:root:Importer beancount.ingest.importers.csv.Importer:
"Expenses:Amazon".extract() raised an unexpected error: Unknown string
format: order date
Traceback (most recent call last):
File
"/home/user/beancount/.venv/lib/python3.10/site-packages/beancount/ingest/extract.py",
line 182, in extract
new_entries = extract_from_file(
File
"/home/user/beancount/.venv/lib/python3.10/site-packages/beancount/ingest/extract.py",
line 67, in extract_from_file
new_entries = importer.extract(file, **kwargs)
File
"/home/user/beancount/.venv/lib/python3.10/site-packages/beancount/ingest/importers/csv.py",
line 294, in extract
date = parse_date_liberally(date, self.dateutil_kwds)
File
"/home/user/beancount/.venv/lib/python3.10/site-packages/beancount/utils/date_utils.py",
line 45, in parse_date_liberally
return dateutil.parser.parse(string, **parse_kwargs_dict).date()
File
"/home/user/beancount/.venv/lib/python3.10/site-packages/dateutil/parser/_parser.py",
line 1368, in parse
return DEFAULTPARSER.parse(timestr, **kwargs)
File
"/home/user/beancount/.venv/lib/python3.10/site-packages/dateutil/parser/_parser.py",
line 643, in parse
raise ParserError("Unknown string format: %s", timestr)
dateutil.parser._parser.ParserError: Unknown string format: order date
;; -*- mode: beancount -*-
```
What annoys me the most here is, that I cannot find a way to just call the
`bean-extract config_amazon_csv.py amazon_order_history_2022.csv` part just
from the `config_amazon_csv.py` file or another python script.
That would make it easy to set a breakpoint in my editor to check what is
happening exactly.
As I'm quite new to python: what is the proper way of calling bean-extract
for debugging purposes?
So any pointers highly appreciated to get my amazon transactions to
beancount format.
Moritz
--
You received this message because you are subscribed to the Google Groups
"Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/beancount/1ca6073c-989c-4d66-8e16-6293b8195619n%40googlegroups.com.