Skip to content
master
Go to file
Code

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

hledger-import-dsl

Warning: This currently has hack status. I don't know if it will be useful or even work for anything other than my personal use case.

A Haskell library that (somewhat) replaces CSV import rules for hledger. It provides a simple lensy DSL that somewhat resembles hledger's own import rules but is more powerful as it embeds arbitrary Haskell.

Usage

  1. Create a .rules file that allows hledger to import the CSV and generates transactions which contain all fields that you'd want to match on in the description.

  2. Write a Haskell program using the DSL provided by this library (see example below).

  3. Run your program: programname CSVFILE

Example

{-# LANGUAGE OverloadedStrings #-}

module Main where

import qualified Hledger.Data as HL
import           Hledger.Data.Lenses
import           Hledger.Import
import           Lens.Micro.Platform

addEuro :: Rule
addEuro = rule ".*" $ do
  zoom (tpostingsL . each . pamountL . mixed . each) $ do
    acommodityL .= ""
    astyleL . ascommoditysideL .= HL.R

main :: IO ()
main = defaultMain
  [ rule ".*" $ tcommentL .= "bankxy:"
  , addEuro
  , rule "Donation" $
      posting "Account2" . paccountL .= "Income:Bribes"
  ]

About

No description, website, or topics provided.

Resources

License

Releases

No releases published

Packages

No packages published