Safe Haskell | None |
---|---|
Language | Haskell2010 |
A reader for CSV data, using an extra rules file to help interpret the data.
Synopsis
- reader :: Reader
- type CsvRecord = [String]
- type CSV = [Record]
- type Record = [Field]
- type Field = String
- rulesFileFor :: FilePath -> FilePath
- parseRulesFile :: FilePath -> ExceptT String IO CsvRules
- parseAndValidateCsvRules :: FilePath -> Text -> Either String CsvRules
- expandIncludes :: FilePath -> Text -> IO Text
- transactionFromCsvRecord :: SourcePos -> CsvRules -> CsvRecord -> Transaction
- printCSV :: CSV -> String
- tests_CsvReader :: TestTree
Reader
Misc.
rulesFileFor :: FilePath -> FilePath Source #
parseRulesFile :: FilePath -> ExceptT String IO CsvRules Source #
An pure-exception-throwing IO action that parses this file's content as CSV conversion rules, interpolating any included files first, and runs some extra validation checks.
parseAndValidateCsvRules :: FilePath -> Text -> Either String CsvRules Source #
An error-throwing IO action that parses this text as CSV conversion rules and runs some extra validation checks. The file path is used in error messages.
expandIncludes :: FilePath -> Text -> IO Text Source #
Inline all files referenced by include directives in this hledger CSV rules text, recursively. Included file paths may be relative to the directory of the provided file path. This is done as a pre-parse step to simplify the CSV rules parser.
transactionFromCsvRecord :: SourcePos -> CsvRules -> CsvRecord -> Transaction Source #