hledger/hledger/Hledger/Cli/Commands/Import.md

1.8 KiB
Raw Blame History

import
Read new transactions added to each FILE since last run, and add them to the main journal file. Or with dry-run, just print the transactions that would be added. Or with catchup, just mark all of the FILEs transactions as imported, without actually importing any.

_FLAGS

The input files are specified as arguments - no need to write -f before each one. So eg to add new transactions from all CSV files to the main journal, its just: hledger import *.csv

New transactions are detected in the same way as print new: by assuming transactions are always added to the input files in increasing date order, and by saving .latest.FILE state files.

The dry-run output is in journal format, so you can filter it, eg to see only uncategorised transactions:

$ hledger import --dry ... | hledger -f- print unknown --ignore-assertions

Importing balance assignments

Entries added by import will have their posting amounts made explicit (like hledger print -x). This means that any balance assignments in imported files must be evaluated; but, imported files dont get to see the main files account balances. As a result, importing entries with balance assignments (eg from an institution that provides only balances and not posting amounts) will probably generate incorrect posting amounts. To avoid this problem, use print instead of import:

$ hledger print IMPORTFILE [--new] >> $LEDGER_FILE

(If you think import should leave amounts implicit like print does, please test it and send a pull request.)

Commodity display styles

Imported amounts will be formatted according to the canonical commodity styles (declared or inferred) in the main journal file.