Hledger / Import Transactions From Single File
Import Transactions From Single File
Imports transactions from a specified single CSV file into hledger's journal.
hledger import <path/to/bank.csv> hledger import <path/to/bank.csv> #!/bin/bash
# Import Transactions From Single File
hledger import {{path/to/bank.csv}} import subprocess
# Import Transactions From Single File
# Make sure to replace <placeholders> with actual values
def run_command():
cmd = [
"hledger",
"import",
"<path/to/bank.csv>"
]
try:
print(f"Executing: {' '.join(cmd)}")
subprocess.run(cmd, check=True)
except subprocess.CalledProcessError as e:
print(f"Error: {e}")
except FileNotFoundError:
print("Error: hledger not found. Please install it first.")
if __name__ == "__main__":
run_command() When To Use
During routine bank reconciliation tasks where a single file is involved.
Pro Tip
Utilize the `--dry-run` flag first to validate potential imports without writing to the journal.
Command Builder
Tune the command before you copy it
hledger import <path/to/bank.csv> Anatomy of Output
Understanding the result
Processing CSV file: path/to/bank.csv File Status Indicates the file being processed.
Imported 42 transactions, 5 errors Import Summary Number of transactions successfully imported versus errors encountered.
Total Amount: $54.78 Balance Summary Summary total calculated from imported transactions.
Troubleshooting
Common pitfalls
Error: File not found: path/to/bank.csv
Solution: Check the path and filename; ensure the file exists.
Error: Invalid CSV format
Solution: Ensure the CSV complies with expected delimiters and formats.
Error: Duplicate transaction detected
Solution: Check the file for duplicate entries before import.
Command Breakdown
What each part is doing
-
hledger - Base Command
- The executable that performs this operation. Here it runs Hledger before the shell applies any redirect operators.
-
<path/to/bank.csv> - path to bank.csv
- The value supplied for path to bank.csv.
Alternative Approaches
Comparable commands in other tools
Alternative data processing tools for the same job.
gdown --fuzzy <url> Picotool / Convert Elf Bin To Uf2 picotool uf2 convert <path/to/elf_or_bin> <path/to/output> Aws / List Glue Jobs aws glue list-jobs Aws / List Triggers aws glue list-triggers Aws / Create Dev Endpoint aws glue create-dev-endpoint --endpoint-name <name> --role-arn <role_arn_used_by_endpoint>