Add org/README.org
This commit is contained in:
parent
a303636dfe
commit
57a6a5fa90
33
org/README.org
Normal file
33
org/README.org
Normal file
|
@ -0,0 +1,33 @@
|
|||
Here is an example of how I was using =org-babel= with =babashka= to generate the command flags needed by [invoice](https://github.com/maaslalani/invoice)
|
||||
|
||||
#+begin_example
|
||||
#+NAME: table-of-data
|
||||
| Transaction Date | Post Date | Description | Category | Type | Amount | Memo |
|
||||
|------------------+------------+----------------------------------+-----------+------+----------+------|
|
||||
| 12/01/2023 | 12/02/2023 | Big Expense Number 1 | Shopping | Sale | -2414.73 | |
|
||||
| 12/02/2023 | 12/03/2023 | Some Other Expense | Personal | Sale | -95.00 | |
|
||||
| 12/03/2023 | 12/04/2023 | This Expense You Don't Recognize | Groceries | Sale | -20.82 | |
|
||||
|
||||
#+NAME: table-to-lines
|
||||
#+begin_src clojure :colnames no :var input=table-of-data :exports results :results output
|
||||
(let [[header & data] input
|
||||
rows (->> data
|
||||
(reduce (fn [state row]
|
||||
(conj state
|
||||
(zipmap header
|
||||
row)))
|
||||
[]))]
|
||||
(doseq [{:strs [Description Amount]} (butlast rows)]
|
||||
(println (format "--item \"%s\" --quantity 1 --rate %.2f \\"
|
||||
Description Amount)))
|
||||
(let [{:strs [Description Amount]} (last rows)]
|
||||
(print (format "--item \"%s\" --quantity 1 --rate %.2f \\"
|
||||
Description Amount))))
|
||||
#+end_src
|
||||
|
||||
#+RESULTS: table-to-lines
|
||||
: --item "Big Expense Number 1" --quantity 1 --rate -2414.73 \
|
||||
: --item "Some Other Expense" --quantity 1 --rate -95.00 \
|
||||
: --item "This Expense You Don't Recognize" --quantity 1 --rate -20.82 \
|
||||
|
||||
#+end_example
|
Loading…
Reference in a new issue