Skip to content

CLI Reference

The bsp command-line tool provides subcommands for processing bank statement PDFs and anonymising PDF files. Install the package to get the bsp entry point:

pip install uk-bank-statement-parser

bsp forex

Fetches daily USD-based exchange rates for all currencies found in DimAccount plus any extras specified, forward-fills weekend and holiday gaps, and writes the results to the exchange_rates table. Provider and API key can be configured via forex_api_config.toml in the project config directory.

bsp forex [--project PATH] [--currencies CODE] [--api-key KEY]

Options

Option Default Description
--project auto-detect Project folder path (default: ./bsp_project/ in CWD).
--currencies auto-detect Additional ISO 4217 currency codes to fetch (e.g. --currencies AED SAR).
--api-key auto-detect Override the API key from forex_api_config.toml. Prefer setting the BSP_FOREX_API_KEY environment variable instead to avoid key exposure in shell history.

bsp anonymise

Anonymise a single bank statement PDF by scrambling all personal data while preserving document structure. Dates, payment codes, and numeric identifiers (sort codes, account numbers, IBANs, card numbers) are handled deterministically. Requires: pip install uk-bank-statement-parser[anonymise]

bsp anonymise PDF [--output OUT_FILE] [--always-anonymise TOML] [--never-anonymise TOML] [--debug]

Positional arguments

Argument Description
PDF Path to the PDF file to anonymise.

Options

Option Default Description
--output auto-detect Output path for the anonymised PDF (default: anonymised_.pdf in the same directory as the input). It is strongly recommended to supply an explicit output path that does not contain any sensitive information.
--always-anonymise auto-detect Path to a user always_anonymise.toml file. Entries force specific strings to a known replacement value and take priority over the bundled system file.
--never-anonymise auto-detect Path to a user never_anonymise.toml file. Phrases listed here are preserved exactly as-is and are merged with the bundled system file.
--debug off Print diagnostic information about config loading and scramble pairs.

bsp process

Discover PDF bank statements, extract transaction data, persist results to Parquet and/or SQLite, copy source PDFs into the project tree, and export reports as Excel, CSV, JSON, and/or CSV reporting feeds. A project folder is created automatically if it does not exist.

bsp process [--project PATH] [--pdfs PATH] [--pattern GLOB] [--no-turbo] [--company KEY] [--account KEY] [--data {parquet,database,both}] [--export-format {excel,csv,json,all,reporting}] [--export-type {single,multi}] [--no-export] [--no-copy] [--batch-id ID] [--filename-timestamp]

Options

Option Default Description
--project auto-detect Project folder path. Created if absent (default: ./bsp_project/ in CWD).
--pdfs auto-detect Folder to scan for PDF files (default: current working directory).
--pattern **/*.pdf Glob pattern for PDF discovery (default: '*/.pdf').
--no-turbo off Disable parallel processing (turbo is enabled by default).
--company auto-detect Company key for config lookup (default: auto-detect from PDF).
--account auto-detect Account key for config lookup (default: auto-detect from PDF).
--data both Persistence target for update_data() (default: 'both'). Choices: parquet, database, both.
--export-format all Export file format (default: 'all'). Choices: excel, csv, json, all, reporting.
--export-type single Export preset. 'single' (default) exports a single flat transactions table. 'multi' exports separate star-schema tables (accounts, calendar, statements, transactions, balances, gaps) intended for loading into an external database. Choices: single, multi.
--no-export off Skip the export step entirely.
--no-copy off Skip copying source PDFs into the project statements/ directory.
--batch-id auto-detect Filter exports to a single batch identifier (default: export all batches).
--filename-timestamp off Append a human-readable timestamp (yyyymmddHHMMSS) to exported filenames. For multi exports (CSV/JSON) a timestamped sub-folder is created instead.

Examples

Process all PDFs in a folder

bsp process --pdfs ~/statements

Process with a specific project folder

bsp process --pdfs ~/statements --project ~/my_project

Persist to database only, skip export

bsp process --pdfs ~/statements --data database --no-export

Anonymise a single PDF

bsp anonymise statement.pdf

Anonymise with a safe output filename

bsp anonymise statement.pdf --output safe_output.pdf