# Advice for python scripts with hledger

**URL:** <https://forum.plaintextaccounting.org/t/advice-for-python-scripts-with-hledger/337>\
**Category:** General\
**Tags:** hledger, python\
**Created:** [August 9, 2024, 11:54am UTC](https://forum.plaintextaccounting.org/t/advice-for-python-scripts-with-hledger/337 "2024-08-09T11:54:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![zako](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.plaintextaccounting.org/zako/32/21_2.png) [@zako](https://forum.plaintextaccounting.org/u/zako)\
**Post date:** [August 9, 2024, 11:54am UTC](https://forum.plaintextaccounting.org/t/advice-for-python-scripts-with-hledger/337/1 "2024-08-09T11:54:01Z")

</div>

Hi,

I would like to script some graphs about my savings, investments... The idea would be to generate static graph files or to create jupyter/org-mode notebooks to dynamically recreate them. I think Python with matplotlib could be the solution. However, I do not know how to execute hledger commands and get the output of the commands in Python. Should I use the subprocess module? Do you have any skeleton of one python file to run and parse the output of hledger command?

---

<div class="post-metadata">

**Author:** ![simonmic](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.plaintextaccounting.org/simonmic/32/1_2.png) [@simonmic](https://forum.plaintextaccounting.org/u/simonmic)\
**Post date:** [August 9, 2024, 1:49pm UTC](https://forum.plaintextaccounting.org/t/advice-for-python-scripts-with-hledger/337/2 "2024-08-09T13:49:30Z")

</div>

Hi @zako, have you seen the [Charts and Graphs - hledger](https://hledger.org/charts.html) page ? hledger-plot sounds like a good option..

---

<div class="post-metadata">

**Author:** ![zako](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.plaintextaccounting.org/zako/32/21_2.png) [@zako](https://forum.plaintextaccounting.org/u/zako)\
**Post date:** [August 9, 2024, 5:43pm UTC](https://forum.plaintextaccounting.org/t/advice-for-python-scripts-with-hledger/337/3 "2024-08-09T17:43:18Z")

</div>

Yes, i looked at that webpage and tried several options: years ago with ledger-cli I made custom gnuplot graphs, then with hledger I tried hledger-vega and Paisa.

What I want to create custom graphs which require data manipulation before creating the graphs.

Perhaps hledger-vega was the solution most suitable for this task, because it provides a kind of framework to create queries, export queries results to csv and then create graphs. But Vega specification was a bit complex for my understanding....

---

<div class="post-metadata">

**Author:** ![simonmic](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.plaintextaccounting.org/simonmic/32/1_2.png) [@simonmic](https://forum.plaintextaccounting.org/u/simonmic)\
**Post date:** [August 9, 2024, 8:37pm UTC](https://forum.plaintextaccounting.org/t/advice-for-python-scripts-with-hledger/337/4 "2024-08-09T20:37:51Z")

</div>

Did you try hledger-plot ? It's python and uses matplotlib

---

<div class="post-metadata">

**Author:** ![zako](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.plaintextaccounting.org/zako/32/21_2.png) [@zako](https://forum.plaintextaccounting.org/u/zako)\
**Post date:** [August 10, 2024, 8:11am UTC](https://forum.plaintextaccounting.org/t/advice-for-python-scripts-with-hledger/337/5 "2024-08-10T08:11:27Z")

</div>

No I didn't. I looked at the documentation and I thought it lacks of data manipulation capabilities but I wll check it in more detail.
