This is the entry point to hledger's reading system, which can read Journals from various data formats. Use this module if you want to parse journal data or read journal files. Generally it should not be necessary to import modules below this one.
- defaultJournalPath :: IO String
- defaultJournal :: IO Journal
- readJournal :: Maybe Format -> Maybe FilePath -> Maybe FilePath -> String -> IO (Either String Journal)
- readJournal' :: String -> IO Journal
- readJournalFile :: Maybe Format -> Maybe FilePath -> FilePath -> IO (Either String Journal)
- requireJournalFileExists :: FilePath -> IO ()
- ensureJournalFileExists :: FilePath -> IO ()
- accountname :: GenParser Char st AccountName
- amountp :: GenParser Char JournalContext Amount
- amountp' :: String -> Amount
- mamountp' :: String -> MixedAmount
- code :: GenParser Char JournalContext String
- samplejournal :: IO Journal
- tests_Hledger_Read :: Test
Journal reading API
All the data formats we can read. formats = map rFormat readers
Get the default journal file path specified by the environment.
Like ledger, we look first for the LEDGER_FILE environment
variable, and if that does not exist, for the legacy LEDGER
environment variable. If neither is set, or the value is blank,
return the hard-coded default, which is
.hledger.journal in the
users's home directory (or in the current directory, if we cannot
determine a home directory).
Read the default journal file specified by the environment, or raise an error.
Read a journal from this string, trying whatever readers seem appropriate:
- if a format is specified, try that reader only
- or if one or more readers recognises the file path and data, try those
- otherwise, try them all.
A CSV conversion rules file may also be specified for use by the CSV reader.
Read a journal from the given string, trying all known formats, or simply throw an error.
Read a Journal from this file (or stdin if the filename is -) or give an error message, using the specified data format or trying all known formats. A CSV conversion rules file may be specified for better conversion of that format.
If the specified journal file does not exist, give a helpful error and quit.
Ensure there is a journal file at the given path, creating an empty one if needed.
Parsers used elsewhere
Parse an account name. Account names may have single spaces inside them, and are terminated by two or more spaces. They should have one or more components of at least one character, separated by the account separator char.
Parse a single-commodity amount, with optional symbol on the left or right, optional unit or total price, and optional (ignored) ledger-style balance assertion or fixed lot price declaration.