# CCEW Bulk Register Dataset Reference

How the UK Charity Commission for England & Wales (CCEW) bulk register is structured, what each table contains, and exactly how every field flows into the `charities` table. Source: [load_ccew.py](load_ccew.py), with column maps verified against the CCEW data dictionary and the live extract of 16 May 2026.

---

## 1. How the data is published

CCEW publishes a **single rolling snapshot** of the entire Register of Charities (registered, removed, and linked) at:

```
https://register-of-charities.charitycommission.gov.uk/en/register/full-register-download
```

The page links to ~13 tables, each shipped as a ZIP under **two parallel blob paths**:

- `https://ccewuksprdoneregsadata1.blob.core.windows.net/data/json/<table>.zip` — JSON
- `https://ccewuksprdoneregsadata1.blob.core.windows.net/data/txt/<table>.zip` — tab-delimited `.txt`

**Important:** the docs call them "tab-separated values" — they are *not* pipe-delimited despite the legacy name `read_pipe()` in our loader. Each `.txt` file is a SQL Server BCP dump with one BOM-prefixed header row and `\t` as the column separator. Many activity / objects fields contain blobs above the default Python `csv` field cap (128 KB), so the loader bumps the limit to `sys.maxsize` at import time ([load_ccew.py:24](load_ccew.py#L24)).

Discovery: the loader scrapes the page HTML, filters out `/json/` links, and keeps only the TXT variant of the 9 tables it needs ([load_ccew.py:_zip_urls_from_page](load_ccew.py#L72)).

Unlike CRA, CCEW does **not** publish one dataset per fiscal year. The main `charity` table holds the *current* state of each charity (one row per `registration_number`). Historical financials live inside `charity_annual_return_history` / `_parta` / `_partb`, keyed on `(organisation_number, fin_period_end_date)`. The loader's `--mode latest` collapses to one row per charity; `--mode all` enumerates every AR cycle as its own row and caps each charity at the 5 most recent years ([_cap_years_per_charity](load_ccew.py#L406)).

Linked subsidiaries: a "linked charity" shares its parent's `registered_charity_number` and is distinguished by a non-zero `linked_charity_number`. Every per-charity processor in the loader filters `linked_charity_number = 0` to keep aggregates honest ([_is_parent](load_ccew.py#L181)).

---

## 2. Table inventory (16 May 2026 extract)

| Slug (`_NEEDED_ZIPS`) | Filename | Loaded? | What it holds |
|---|---|---|---|
| `charity` | `publicextract.charity.txt` | ✅ | Identity, address, latest filing totals |
| `charity_annual_return_history` | `publicextract.charity_annual_return_history.txt` | ✅ | Per-cycle gross income / expenditure (every cycle, even sub-£500k) |
| `charity_annual_return_parta` | `publicextract.charity_annual_return_parta.txt` | ✅ (partial) | Section A AR detail — volunteers, salary bands, fundraiser flags |
| `charity_annual_return_partb` | `publicextract.charity_annual_return_partb.txt` | ✅ | Section B AR detail — full revenue / expense / asset breakdown (income > £500k filers only) |
| `charity_area_of_operation` | `publicextract.charity_area_of_operation.txt` | ✅ | One row per country/continent the charity operates in |
| `charity_classification` | `publicextract.charity_classification.txt` | ✅ (partial) | What / How / Who taxonomies — only "What" is consumed |
| `charity_governing_document` | `publicextract.charity_governing_document.txt` | ✅ | Charitable objects (legal mission statement) |
| `charity_policy` | `publicextract.charity_policy.txt` | ✅ | Trustee policy checklist — one row per policy in place |
| `charity_trustee` | `publicextract.charity_trustee.txt` | ✅ | Currently-serving trustees (name, chair flag) |
| — | `publicextract.charity_event_history.txt` | ❌ | Charity-event log (registration, transfer, removal, etc.) |
| — | `publicextract.charity_other_names.txt` | ❌ | Working / previously-used names |
| — | `publicextract.charity_other_regulators.txt` | ❌ | Cross-references to other UK regulators (FCA, OSCR, etc.) |
| — | `publicextract.charity_published_report.txt` | ❌ | Statutory inquiry / warning notices |

The loader skips the 4 ignored tables — none has a destination column in the `charities` schema.

---

## 3. File column reference

Every file has been verified by reading the header row of the live extract.

### `publicextract.charity.txt`
```
date_of_extract, organisation_number, registered_charity_number,
linked_charity_number, charity_name, charity_type,
charity_registration_status, date_of_registration, date_of_removal,
charity_reporting_status, latest_acc_fin_period_start_date,
latest_acc_fin_period_end_date, latest_income, latest_expenditure,
charity_contact_address1..5, charity_contact_postcode,
charity_contact_phone, charity_contact_email, charity_contact_web,
charity_company_registration_number, charity_insolvent,
charity_in_administration, charity_previously_excepted,
charity_is_cdf_or_cif, charity_is_cio, cio_is_dissolved,
date_cio_dissolution_notice, charity_activities, charity_gift_aid,
charity_has_land
```
- **`charity_name`**: main legal name. `linked_charity_number = 0` is the parent record; subsidiaries share the parent's `registered_charity_number`.
- **`latest_income` / `latest_expenditure`**: total gross income / expenditure from Part A of the most recent AR. Used as a coarse fallback before partb is merged.
- **`charity_activities`**: trustees' free-text description of activities. Coarser than `governing_document.charitable_objects`; only used as a mission fallback.
- **`charity_contact_address1..5` + postcode**: five unlabelled address lines. UK convention is roughly `building → street → locality → town → county`. The loader derives `city` from the last populated of lines 5/4/3 ([_city_from_address](load_ccew.py#L196)) and `state` from the postcode outward code ([_state_from_postcode](load_ccew.py#L212)).

### `publicextract.charity_annual_return_history.txt`
```
date_of_extract, organisation_number, registered_charity_number,
fin_period_start_date, fin_period_end_date, ar_cycle_reference,
reporting_due_date, date_annual_return_received, date_accounts_received,
total_gross_income, total_gross_expenditure, accounts_qualified,
suppression_ind, suppression_type
```
Only two financial fields exist here (`total_gross_income`, `total_gross_expenditure`); both used as fallbacks behind partb. **No `linked_charity_number` column** — AR history rows are always parent-keyed.

### `publicextract.charity_annual_return_parta.txt`
```
…organisation_number, registered_charity_number,
latest_fin_period_submitted_ind, fin_period_order_number,
ar_cycle_reference, fin_period_start_date, fin_period_end_date,
ar_due_date, ar_received_date,
total_gross_income, total_gross_expenditure,
charity_raises_funds_from_public, charity_professional_fundraiser,
charity_agreement_professional_fundraiser, charity_commercial_participator,
charity_agreement_commerical_participator, grant_making_is_main_activity,
charity_receives_govt_funding_contracts, count_govt_contracts,
charity_receives_govt_funding_grants, count_govt_grants,
income_from_government_contracts, income_from_government_grants,
charity_has_trading_subsidiary, trustee_also_director_of_subsidiary,
does_trustee_receive_any_benefit, trustee_payments_acting_as_trustee,
trustee_receives_payments_services, trustee_receives_other_benefit,
trustee_resigned_employment, employees_salary_over_60k,
count_salary_band_60001_70000 … count_salary_band_over_500000,
count_volunteers
```
- **`latest_fin_period_submitted_ind`** (TRUE/FALSE): flags the row representing the latest filing. In `latest` mode the loader matches on this to avoid year-mismatch with the meta row.
- **`fin_period_order_number`** (1-5): 1 = most recent. Used as a secondary signal where `latest_fin_period_submitted_ind` is missing.
- **`count_salary_band_*`**: head counts per £10k band from £60k up to £500k+. **CCEW publishes counts only, not amounts.** A charity with 3 people in the £150k-£200k band reports `count_salary_band_150001_200000 = 3` regardless of the actual pay.
- **`count_volunteers`**: trustees' estimate, headcount (not FTE).

### `publicextract.charity_annual_return_partb.txt`
```
…organisation_number, registered_charity_number,
latest_fin_period_submitted_ind, fin_period_order_number,
ar_cycle_reference, fin_period_start_date, fin_period_end_date,
ar_due_date, ar_received_date,
income_donations_and_legacies, income_other_trading_activities,
income_charitable_activities, income_investments, income_other,
income_total_income_and_endowments, income_legacies, income_endowments,
expenditure_raising_funds, expenditure_charitable_expenditure,
expenditure_other, expenditure_total, expenditure_investment_management,
expenditure_grants_institution, expenditure_governance,
expenditure_support_costs, expenditure_depreciation,
gain_loss_investment, gain_loss_pension_fund,
gain_loss_revaluation_fixed_investment, gain_loss_other, reserves,
assets_total_fixed, assets_own_use, assets_long_term_investment,
defined_benefit_pension_scheme, assets_other_assets,
assets_total_liabilities, assets_current_investment,
assets_total_assets_and_liabilities, creditors_one_year_total_current,
creditors_falling_due_after_one_year, assets_cash,
funds_endowment, funds_unrestricted, funds_restricted, funds_total,
count_employees, charity_only_accounts, consolidated_accounts
```
- Filed only by charities with **income > £500k**. About 15-20k of ~354k charities have any partb row.
- **`income_total_income_and_endowments`** is the modern "total revenue" line. **`expenditure_total`** is the total expenditure line. Both override the coarser `total_gross_*` values from AR history.

### `publicextract.charity_area_of_operation.txt`
```
…organisation_number, registered_charity_number, linked_charity_number,
geographic_area_type, geographic_area_description,
parent_geographic_area_type, parent_geographic_area_description, welsh_ind
```
One row per area declared. `geographic_area_type` ∈ {`Country`, `Continent`, `Local Authority`, `Region`, …}. The loader keeps rows where the type is `Country`/`Continent` and the description is **not** one of `ENGLAND, WALES, SCOTLAND, NORTHERN IRELAND, UNITED KINGDOM`, aggregates them into a sorted JSON list per charity ([process_areas](load_ccew.py#L294)).

### `publicextract.charity_classification.txt`
```
…linked_charity_number, classification_code, classification_type,
classification_description
```
- **`classification_type`**: `What` (what the charity does) / `How` (how it helps) / `Who` (who it helps).
- The loader only consumes `What` rows ([process_classification](load_ccew.py#L245)) and uses string keywords on the description to flag `operates_hospital` (`hospital|medic|health`) and `operates_school` (`school|college|educat|training`).
- `How` and `Who` have no obvious destination column and are ignored.

### `publicextract.charity_governing_document.txt`
```
…linked_charity_number, governing_document_description,
charitable_objects, area_of_benefit
```
- **`charitable_objects`**: the formal legal purpose statement. Richer and more reliable than `charity_activities`; used as `mission` ([process_governing](load_ccew.py#L235)).
- **`governing_document_description`** and **`area_of_benefit`** are not loaded.

### `publicextract.charity_policy.txt`
```
…linked_charity_number, policy_name
```
Many rows per charity — one per declared policy. `policy_name` is free text from a curated CCEW list. The loader runs three regex matchers ([_POLICY_RULES](load_ccew.py#L266)):

| Pattern | DB column |
|---|---|
| `conflict` | `conflict_policy` |
| `whistleblow` OR `serious incident` | `whistleblower_policy` |
| `retention` OR `preserv` | `doc_retention_policy` |

The `serious incident` clause exists because UK Charity Commission guidance treats "Serious incident reporting" as the local equivalent of US whistleblower policies — that's the canonical CCEW policy name.

### `publicextract.charity_trustee.txt`
```
…linked_charity_number, trustee_id, trustee_name, trustee_is_chair,
individual_or_organisation, trustee_date_of_appointment
```
- One row per *currently-serving* trustee (resigned trustees not included).
- Loader counts rows per `registered_charity_number` (parent only) → `voting_members`, and grabs the first row with `trustee_is_chair = TRUE` → `ceo_name`, `ceo_title = "Chair"` ([process_trustee](load_ccew.py#L283)).

---

## 4. `charities` column → CCEW source map

`SHARED_COLUMNS` is defined in [loader_common.py:25-43](loader_common.py#L25-L43). Below: each column, where the CCEW value comes from, and the function that writes it.

### Identity & metadata

| Column | CCEW source | Writer |
|---|---|---|
| `country_code` | constant `"GB"` | [_make_row()](load_ccew.py#L424) |
| `sub_jurisdiction` | constant `"EW"` | _make_row |
| `data_source` | constant `"CCEW"` | _make_row |
| `form_type` | constant `"AR"` (Annual Return) | _make_row |
| `registration_number` | `charity.registered_charity_number` | [process_charity_meta()](load_ccew.py#L223) |
| `name` | `charity.charity_name` (parent only) | process_charity_meta |
| `tax_year` | `charity.latest_acc_fin_period_end_date` year (latest mode) / `ar_history.fin_period_end_date` year (all mode) | [build_rows()](load_ccew.py#L444) |
| `city` | last populated of `charity.charity_contact_address5/4/3` | [_city_from_address()](load_ccew.py#L196) |
| `state` | outward postcode (e.g. `"EC2Y"` from `"EC2Y 9AL"`) | [_state_from_postcode()](load_ccew.py#L212) |
| `ein` | always NULL (US-only concept) | — |

### Officer / compensation

| Column | CCEW source | Writer |
|---|---|---|
| `ceo_name` | `charity_trustee.trustee_name` where `trustee_is_chair = TRUE` | [process_trustee()](load_ccew.py#L283) |
| `ceo_title` | constant `"Chair"` when a chair is found | process_trustee |
| `voting_members` | count of `charity_trustee` rows per `registered_charity_number` | process_trustee |
| `employees` | `charity_ar_partb.count_employees` | [_apply_partb_row()](load_ccew.py#L323) |
| `volunteers` | `charity_ar_parta.count_volunteers` | [_apply_parta_row()](load_ccew.py#L341) |

### Financials

| Column | CCEW source | Writer |
|---|---|---|
| `total_revenue` | `partb.income_total_income_and_endowments` → fallback `ar_history.total_gross_income` → fallback `charity.latest_income` | _apply_partb_row / build_rows |
| `total_expenses` | `partb.expenditure_total` → fallback `ar_history.total_gross_expenditure` → fallback `charity.latest_expenditure` | _apply_partb_row / build_rows |
| `program_expenses` | `partb.expenditure_charitable_expenditure` | _apply_partb_row |
| `mgmt_expenses` | `partb.expenditure_governance` | _apply_partb_row |
| `fundraising_expenses` | `partb.expenditure_raising_funds` | _apply_partb_row |
| `grants_paid` | `partb.expenditure_grants_institution` | _apply_partb_row |
| `total_assets` | `partb.assets_total_fixed` | _apply_partb_row |
| `net_assets` | `partb.assets_total_assets_and_liabilities` | _apply_partb_row |

### Programs & mission

| Column | CCEW source | Writer |
|---|---|---|
| `mission` | `governing_document.charitable_objects` (preferred) → fallback `charity.charity_activities` | [process_governing()](load_ccew.py#L235) / process_charity_meta |
| `program_desc1/2/3` | first 3 `charity_classification.classification_description` rows where `classification_type = "What"` | [process_classification()](load_ccew.py#L245) |
| `program_count` | count of `What` classification rows per charity | process_classification |
| `operates_hospital` | regex `hospital\|medic\|health` against `What` classifications | process_classification |
| `operates_school` | regex `school\|college\|educat\|training` against `What` classifications | process_classification |

### Governance policies

| Column | CCEW source | Writer |
|---|---|---|
| `conflict_policy` | any `charity_policy.policy_name` matching `conflict` | [process_policy()](load_ccew.py#L274) |
| `whistleblower_policy` | any `policy_name` matching `whistleblow\|serious incident` | process_policy |
| `grants_to_orgs` | `charity_ar_parta.grant_making_is_main_activity = TRUE` | _apply_parta_row |

### Foreign activity

| Column | CCEW source | Writer |
|---|---|---|
| `foreign_countries` | sorted JSON list from `charity_area_of_operation` (type ∈ {Country, Continent}, excluding England/Wales/Scotland/NI/UK) | [process_areas()](load_ccew.py#L294) |
| `foreign_activities` | 1 if any non-UK area declared | build_rows |

---

## 5. Columns with **no** CCEW mapping (always NULL/0 on CCEW rows)

These columns are either US-form-specific (IRS Form 990 fields) or simply not collected by the UK Charity Commission. They will be NULL / 0 for every CCEW-sourced row.

### Not asked by CCEW

| Column | Why no source |
|---|---|
| `salaries` | CCEW publishes salary band *head counts* (parta `count_salary_band_*`) but no total wage bill — no field aggregates compensation |
| `ceo_comp` | CCEW does not publish individual salaries; only banded counts of >£60k earners |
| `independent_members` | Trustee independence is not a CCEW data point |
| `doc_retention_policy` | "Document retention" is not in CCEW's policy taxonomy (the policy table covers Conflicts, Safeguarding, Financial controls, Reserves, Serious incident reporting, etc.) |
| `form990_to_board` | US-specific (Form 990 disclosure-to-board question) |
| `audited` | Not a single boolean in CCEW; statutory audit threshold and accounts qualification are split across `ar_history.accounts_qualified` (which means a *qualified* opinion, not just audited) and partb's `charity_only_accounts` flag |
| `comp_process_ceo` | CCEW does not probe CEO comp-setting process |
| `grants_to_individuals` | partb has `expenditure_grants_institution` (grants to other institutions) only |
| `foreign_expenditures` | **CCEW does not publish geographically-split spending.** `area_of_operation` lists where a charity operates but not how much it spends there |
| `foreign_grant_regions` | same — no per-country amount data |
| `foreign_individual_regions` | same |
| `foreign_offices` | Not asked |
| `foreign_employees` | Not asked |
| `gross_receipts` | partb's `income_donations_and_legacies` is the nearest analog but conceptually different from the US "gross receipts" line |
| `total_revenue_py` | Bulk register is a snapshot in time, not annual datasets — prior-year requires retaining last year's extract before reloading |

### US tax-code concepts (will never apply)

| Column | Reason |
|---|---|
| `is_501c3` | US tax-code concept |
| `described_501c3` | US tax-code concept |
| `schedule_a_filed` | US Form 990 Schedule A |
| `schedule_f_filed` | US Form 990 Schedule F |

### Calculated downstream (not loader's job)

`score_composite`, `score_revenue`, `score_religious`, `score_recipient`, `score_results` — populated by [CharityScoreCalculator](app/Services/CharityScoreCalculator.php).

### CCEW data published but currently ignored

Potential enrichments waiting to be wired:

| Source | Could populate |
|---|---|
| `charity.charity_contact_web` | (new column) charity website |
| `charity.charity_contact_email` / `phone` | (new columns) contact details |
| `charity.charity_company_registration_number` | (new column) Companies House number — distinct from charity registration |
| `charity.charity_insolvent` / `charity_in_administration` / `date_of_removal` | status filters (currently the loader ingests removed charities indistinguishably from active ones) |
| `charity.charity_is_cio` / `cio_is_dissolved` | legal-form filters |
| `governing_document.area_of_benefit` | geographic scope narrative |
| `governing_document.governing_document_description` | governance metadata |
| `classification` rows where `type = "How"` or `"Who"` | beneficiary / delivery-method taxonomies |
| `charity_other_names` | working-name / former-name search |
| `charity_published_report` | inquiry / warning notices (regulatory risk flag) |
| `charity_other_regulators` | dual-regulation cross-references |
| `parta.count_salary_band_*` + `employees_salary_over_60k` | best-effort lower bound on `salaries` (Σ band-midpoint × count) |
| `parta.income_from_government_grants` / `income_from_government_contracts` | breakdown of public funding share |
| `parta.charity_professional_fundraiser` / `charity_commercial_participator` | fundraising-method flags |
| `partb.funds_endowment` / `funds_restricted` / `funds_unrestricted` | restricted-fund analysis |
| `partb.consolidated_accounts` | parent/subsidiary financial scope |
| `ar_history.accounts_qualified` + `suppression_ind` | data-quality flags |

---

## 6. Caveats and known issues

1. **Partb is only filed by large charities.** CCEW requires the Section B return only when annual income exceeds £500k. About 15-20k of ~354k charities ever produce a partb row, so `program_expenses`, `fundraising_expenses`, `mgmt_expenses`, `grants_paid`, `total_assets`, `net_assets`, and `employees` are NULL for the vast majority of CCEW rows. The remaining ~340k charities still get `total_revenue` and `total_expenses` from `charity.latest_income` / `latest_expenditure` or from `ar_history.total_gross_*`, but no expense breakdown.

2. **No total salaries field.** CCEW does not publish a payroll line. Parta gives banded *head counts* of >£60k earners and a total head count, partb gives `count_employees`, but nothing sums to a wage bill. `salaries` is therefore NULL on every CCEW row.

3. **No geographic expenditure breakdown.** Schedule 2-equivalent data does not exist in CCEW. `area_of_operation` reveals *where* a charity operates but not *how much* it spends there. `foreign_expenditures`, `foreign_grant_regions`, `foreign_individual_regions`, `foreign_offices`, and `foreign_employees` are all NULL — even for very large internationally-active charities like the British Red Cross (reg 220949).

4. **Single snapshot, not annual datasets.** Unlike CRA (one CKAN dataset per fiscal year), CCEW publishes one rolling extract. To get multi-year coverage we synthesise it from `charity_annual_return_history` cycles, capped at the 5 most recent years per charity by [_cap_years_per_charity()](load_ccew.py#L406). Reloading the bulk extract overwrites the snapshot; historical comparison requires keeping prior extracts around.

5. **`operates_hospital` and `operates_school` are keyword heuristics.** They match against the free-text `classification.classification_description` ("What" type only). The match list is broad (`hospital|medic|health`, `school|college|educat|training`) so expect false positives — a charity with classification "Mental health support" will flag `operates_hospital = 1` even if it operates no hospitals.

6. **`ceo_name` is the trustee chair, not the operational head.** Most UK charities are governed by a volunteer board with no equivalent of a US CEO. The loader populates `ceo_name` from `charity_trustee.trustee_is_chair = TRUE` because that's the closest single-person analog. The actual chief executive may not appear in CCEW's trustee table at all (executives who aren't board members are not listed).

7. **Address parsing is heuristic.** CCEW publishes five unlabelled address lines plus a postcode. The loader picks the last populated of lines 5/4/3 as `city` (UK convention puts town toward the end of the address), and the postcode outward area (e.g. `EC2Y`) as `state`. Both are approximations — an address whose town sits on line 2 will be misclassified.

8. **Linked subsidiaries are dropped, not merged.** A charity with `linked_charity_number > 0` shares the parent's `registered_charity_number` but is otherwise separate. The loader keeps only `linked_charity_number = 0` rows to avoid double-counting trustees, classifications, policies, etc. Subsidiaries are not currently surfaced anywhere.

9. **Latest mode uses `latest_fin_period_submitted_ind`, not year matching.** In `--mode latest`, partb/parta data is merged by the boolean flag rather than by joining on `(reg, year)`. This avoids mismatches where the meta row's `tax_year` came from `date_of_registration` (no filings yet) but a partb row for an earlier cycle exists.

10. **`whistleblower_policy` maps to "Serious incident reporting".** UK charities don't typically write whistleblower policies under that name; the Charity Commission's standard policy catalogue uses "Serious incident reporting" instead. The regex matches both terms to populate the column, but the underlying concept is slightly broader than the US 990 whistleblower-policy definition.

11. **Removed charities are included.** `charity.charity_registration_status` can be `Removed`, with a non-null `date_of_removal`. The loader ingests these rows alongside active charities; downstream consumers should filter on status if they only want currently-registered orgs.
