CSV importer - skip_last_lines?

168 views
Skip to first unread message

Colton Crivelli

unread,
Jun 3, 2022, 1:08:15 AM6/3/22
to Beancount
Hey all - CSVs downloaded from Fidelity not only start with some rows to skip but they end in about 11 garbage rows.

I think there's probably a clean solution of adding a skip_last_lines that leverages the existing skip_lines logic (from csv.py)

Anyone know if something like this has been done anywhere? I'm not comfortable enough with csv.py to try to implement that from scratch

Red S

unread,
Jun 3, 2022, 1:49:18 PM6/3/22
to Beancount
I haven't used csv.py in a while, but use beancount_reds_importers (I'm the author).

If your fidelity csv file looks like this, then the fidelity_csv importer in beancount_reds_importers should work for you. It is under development, but should work for the most part (might be missing a few transaction_type_maps). It already has "skip_tail_rows" in its config.

Easiest way to install, if you're interested is:

Hope that helps.

Colton Crivelli

unread,
Jun 3, 2022, 10:22:44 PM6/3/22
to Beancount
I had a desire to try to keep things as minimal as possible and work towards understanding what's actually going on before adding something like beancount_reds (it comes up basically whenever I google an import question) but taking a look at your example, it does look like it's going to save me a lot of time getting my fidelity data imported
 
One question -- have you considered adding support for csv files from Fidelity that have multiple accounts? Here's the scenario:
  • I have many fidelity accounts
  • I can export a csv for each one, which would match your example here exactly 
  • I can also go to "all accounts" in fidelity and export one csv for everything (columns are `Run Date,Account,Action...` instead of `Run Date,Action...`)
  • Significant reduction in CSV files that need to be downloaded but some code would need to leverage the account column to dynamically update the Assets:Fidelity:<account> entry for beancount
Appreciating the guidance.

Red S

unread,
Jun 3, 2022, 11:09:16 PM6/3/22
to Beancount
Yes, that's easy. Can you send an example .csv without your private data? Or paste a sample row, and the header row here.

Red S

unread,
Jun 4, 2022, 11:25:05 PM6/4/22
to Beancount
Thanks for the example (which was sent offline to me). Done here. Use the same pip command to install.

See the run_test.bash here and fidelity_csv.import in the same directory for an example of how to extract different accounts.

The importer is only for brokerage transactions. Your example contained what looked like a checking account, for which it should be trivial to write a banking importer in beancount-reds-importers.

Which leads me to ask: have you tried using ofx? See this article: A Word About Input Formats - Use OFX When You Can

The fidelity ofx importer in beancount-reds-importers works well. You don't even need to use your browser, you can set it up to direct download.
Reply all
Reply to author
Forward
0 new messages