hledger-0.10: A command-line (or curses or web-based) double-entry accounting tool.Source codeContentsIndex
Hledger.Cli.Commands.Convert
Description
Convert account data in CSV format (eg downloaded from a bank) to ledger format, and print it on stdout. See the manual for more details.
Synopsis
data CsvRules = CsvRules {
dateField :: Maybe FieldPosition
statusField :: Maybe FieldPosition
codeField :: Maybe FieldPosition
descriptionField :: Maybe FieldPosition
amountField :: Maybe FieldPosition
currencyField :: Maybe FieldPosition
baseCurrency :: Maybe String
baseAccount :: AccountName
accountRules :: [AccountRule]
}
type FieldPosition = Int
type AccountRule = ([(String, Maybe String)], AccountName)
type CsvRecord = [String]
convert :: [Opt] -> [String] -> Journal -> IO ()
maxFieldIndex :: CsvRules -> Int
rulesFileFor :: FilePath -> FilePath
initialRulesFileContent :: String
parseCsvRulesFile :: FilePath -> IO (Either ParseError CsvRules)
parseCsvRules :: FilePath -> String -> Either ParseError CsvRules
csvrulesfile :: GenParser Char CsvRules CsvRules
definitions :: GenParser Char CsvRules ()
accountrule :: GenParser Char CsvRules AccountRule
printTxn :: Bool -> CsvRules -> CsvRecord -> IO ()
transactionFromCsvRecord :: CsvRules -> CsvRecord -> Transaction
normaliseDate :: String -> String
identify :: [AccountRule] -> String -> String -> (String, String)
Documentation
data CsvRules Source
A set of data definitions and account-matching patterns sufficient to convert a particular CSV data file into meaningful ledger transactions. See above.
Constructors
CsvRules
dateField :: Maybe FieldPosition
statusField :: Maybe FieldPosition
codeField :: Maybe FieldPosition
descriptionField :: Maybe FieldPosition
amountField :: Maybe FieldPosition
currencyField :: Maybe FieldPosition
baseCurrency :: Maybe String
baseAccount :: AccountName
accountRules :: [AccountRule]
show/hide Instances
type FieldPosition = IntSource
type AccountRule = ([(String, Maybe String)], AccountName)Source
type CsvRecord = [String]Source
convert :: [Opt] -> [String] -> Journal -> 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 :: FilePath -> FilePathSource
initialRulesFileContent :: StringSource
parseCsvRulesFile :: FilePath -> IO (Either ParseError CsvRules)Source
parseCsvRules :: FilePath -> String -> Either ParseError CsvRulesSource
csvrulesfile :: GenParser Char CsvRules CsvRulesSource
definitions :: GenParser Char CsvRules ()Source
Real independent parser choice, even when alternative matches share a prefix.
accountrule :: GenParser Char CsvRules AccountRuleSource
printTxn :: Bool -> CsvRules -> CsvRecord -> IO ()Source
transactionFromCsvRecord :: CsvRules -> CsvRecord -> TransactionSource
normaliseDate :: String -> StringSource
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.
Produced by Haddock version 2.6.1