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 StorageFormat -> Maybe FilePath -> Maybe FilePath -> String -> IO (Either String Journal)
- readJournal' :: String -> IO Journal
- readJournalFile :: Maybe StorageFormat -> Maybe FilePath -> FilePath -> IO (Either String Journal)
- requireJournalFileExists :: FilePath -> IO ()
- ensureJournalFileExists :: FilePath -> IO ()
- postingp :: GenParser Char JournalContext Posting
- accountnamep :: GenParser Char st AccountName
- amountp :: GenParser Char JournalContext Amount
- amountp' :: String -> Amount
- mamountp' :: String -> MixedAmount
- numberp :: GenParser Char JournalContext (Quantity, Int, Char, Char, [Int])
- codep :: 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.
Parse a numeric quantity for its value and display attributes. Some international number formats (cf http:en.wikipedia.orgwikiDecimal_separator) are accepted: either period or comma may be used for the decimal point, and the other of these may be used for separating digit groups in the integer part (eg a thousands separator). This returns the numeric value, the precision (number of digits to the right of the decimal point), the decimal point and separator characters (defaulting to . and ,), and the positions of separators (counting leftward from the decimal point, the last is assumed to repeat).