Safe Haskell | Safe-Infered |
---|
Hledger.Cli.Convert
Description
Convert account data in CSV format (eg downloaded from a bank) to journal format, and print it on stdout. See the manual for more details.
- data CsvRules = CsvRules {
- dateField :: Maybe FieldPosition
- dateFormat :: Maybe String
- statusField :: Maybe FieldPosition
- codeField :: Maybe FieldPosition
- descriptionField :: [FormatString]
- amountField :: Maybe FieldPosition
- amountInField :: Maybe FieldPosition
- amountOutField :: Maybe FieldPosition
- currencyField :: Maybe FieldPosition
- baseCurrency :: Maybe String
- accountField :: Maybe FieldPosition
- account2Field :: Maybe FieldPosition
- effectiveDateField :: Maybe FieldPosition
- baseAccount :: AccountName
- accountRules :: [AccountRule]
- nullrules :: CsvRules
- type FieldPosition = Int
- type AccountRule = ([(String, Maybe String)], AccountName)
- type CsvRecord = [String]
- convert :: CliOpts -> IO ()
- parseCsv :: FilePath -> IO (Either ParseError CSV)
- maxFieldIndex :: CsvRules -> Int
- rulesFileFor :: CliOpts -> FilePath -> FilePath
- initialRulesFileContent :: String
- validateRules :: CsvRules -> Maybe String
- parseCsvRulesFile :: FilePath -> IO (Either ParseError CsvRules)
- parseCsvRules :: FilePath -> String -> Either ParseError CsvRules
- csvrulesfile :: GenParser Char CsvRules CsvRules
- definitions :: GenParser Char CsvRules ()
- datefield :: ParsecT [Char] CsvRules Identity ()
- effectivedatefield :: ParsecT [Char] CsvRules Identity ()
- dateformat :: ParsecT [Char] CsvRules Identity ()
- codefield :: ParsecT [Char] CsvRules Identity ()
- statusfield :: ParsecT [Char] CsvRules Identity ()
- descriptionFieldValue :: GenParser Char st [FormatString]
- descriptionfield :: ParsecT [Char] CsvRules Identity ()
- amountfield :: ParsecT [Char] CsvRules Identity ()
- amountinfield :: ParsecT [Char] CsvRules Identity ()
- amountoutfield :: ParsecT [Char] CsvRules Identity ()
- currencyfield :: ParsecT [Char] CsvRules Identity ()
- accountfield :: ParsecT [Char] CsvRules Identity ()
- account2field :: ParsecT [Char] CsvRules Identity ()
- basecurrency :: ParsecT [Char] CsvRules Identity ()
- baseaccount :: ParsecT [Char] CsvRules Identity ()
- accountrule :: GenParser Char CsvRules AccountRule
- blanklines :: ParsecT [Char] u Identity [()]
- blankline :: ParsecT [Char] u Identity ()
- commentchar :: ParsecT [Char] u Identity Char
- commentline :: ParsecT [Char] u Identity ()
- blankorcommentline :: GenParser Char st ()
- matchreplacepattern :: ParsecT [Char] u Identity ([Char], Maybe [Char])
- formatD :: CsvRecord -> Bool -> Maybe Int -> Maybe Int -> Field -> String
- formatDescription :: CsvRecord -> [FormatString] -> String
- transactionFromCsvRecord :: CsvRules -> CsvRecord -> Transaction
- normaliseDate :: Maybe String -> String -> String
- identify :: [AccountRule] -> String -> String -> (String, String)
- caseinsensitive :: [Char] -> [Char]
- getAmount :: CsvRules -> CsvRecord -> String
- tests_Hledger_Cli_Convert :: Test
- test_description_parsing :: [Test]
- test_parser :: [Test]
Documentation
A set of data definitions and account-matching patterns sufficient to convert a particular CSV data file into meaningful journal transactions. See above.
Constructors
type FieldPosition = IntSource
type AccountRule = ([(String, Maybe String)], AccountName)Source
convert :: CliOpts -> IO ()Source
Read the CSV file named as an argument and print equivalent journal transactions, using/creating a .rules file.
maxFieldIndex :: CsvRules -> IntSource
The highest (0-based) field index referenced in the field definitions, or -1 if no fields are defined.
rulesFileFor :: CliOpts -> FilePath -> FilePathSource
effectivedatefield :: ParsecT [Char] CsvRules Identity ()Source
dateformat :: ParsecT [Char] CsvRules Identity ()Source
statusfield :: ParsecT [Char] CsvRules Identity ()Source
descriptionfield :: ParsecT [Char] CsvRules Identity ()Source
amountfield :: ParsecT [Char] CsvRules Identity ()Source
amountinfield :: ParsecT [Char] CsvRules Identity ()Source
amountoutfield :: ParsecT [Char] CsvRules Identity ()Source
currencyfield :: ParsecT [Char] CsvRules Identity ()Source
accountfield :: ParsecT [Char] CsvRules Identity ()Source
account2field :: ParsecT [Char] CsvRules Identity ()Source
basecurrency :: ParsecT [Char] CsvRules Identity ()Source
baseaccount :: ParsecT [Char] CsvRules Identity ()Source
blanklines :: ParsecT [Char] u Identity [()]Source
commentchar :: ParsecT [Char] u Identity CharSource
commentline :: ParsecT [Char] u Identity ()Source
blankorcommentline :: GenParser Char st ()Source
formatDescription :: CsvRecord -> [FormatString] -> StringSource
Arguments
:: Maybe String | User-supplied date format: this should be tried in preference to all others |
-> String | |
-> String |
Convert some date string with unknown format to YYYYMMDD.
identify :: [AccountRule] -> String -> String -> (String, String)Source
Apply account matching rules to a transaction description to obtain the most appropriate account and a new description.
caseinsensitive :: [Char] -> [Char]Source
test_parser :: [Test]Source