account_owner_conflicts

Elixir library and Mix task. Give it a CSV of account and owner pairs. It lists the accounts that name two or more owners (conflicts), how many accounts have exactly one owner, and for each owner how many accounts they hold and how many of those are also held by someone else.

Labels are trimmed and compared case-insensitively; the first spelling seen is the one shown. The same account and owner on two rows counts once, and the number of such repeated rows is reported. Accounts and owners in the conflict list are sorted case-insensitively and owners are joined by " / ". The per-owner table is sorted by conflicting accounts, highest first, then by owner. At most the first 20 conflicts are listed. Percentages have 1 decimal, rounded half up. Extra columns are ignored.

With --strict the task exits 1 when any conflict exists, otherwise 0 (the sample below is run without --strict). Exit code 2 means the input could not be read or the arguments are wrong: an empty account or owner (the row is named), a missing column, no rows, a missing file or an unknown option.

What it does not do: it lists where your own file names two owners. It cannot tell which owner is right, it does not change anything and it reads no outside data.

Part of the OneGTMLab free GTM tools. Background on the idea: folk.

Install

{:account_owner_conflicts, "~> 1.0"}   # in mix.exs deps

Use

CSV columns: account, owner. The sample has 13 rows, two of them repeats of an earlier pair (Gamma with a different letter case, alpha with a different letter case). Seven accounts: Alpha, Gamma, Epsilon and Eta have one owner; Beta, Delta and Zeta have two or more, so 3 of 7 accounts (42.9%) are conflicts.

$ mix account_owner_conflicts sample.csv
rows: 13
repeated rows (same account and owner as an earlier row): 2
accounts: 7
owners: 3
accounts with exactly one owner: 4
accounts with 2 or more owners (conflicts): 3 (42.9% of accounts)
per owner (conflicting accounts desc, then owner):
  Owner B: 4 accounts, 3 also owned by someone else
  Owner A: 4 accounts, 2 also owned by someone else
  Owner C: 3 accounts, 2 also owned by someone else
conflicts:
  Beta: Owner A / Owner B
  Delta: Owner A / Owner B / Owner C
  Zeta: Owner B / Owner C

Test

mix test

Offline, no network calls, no dependencies beyond the language runtime. MIT licensed.