Split a CSV list of ids into groups with a seeded hash.
Input is a CSV with the columns id and segment. The id is trimmed and compared
case-insensitively; the segment is a label (trimmed, case-insensitive, the first
spelling is the one shown).
The group of an id is :erlang.phash2({seed, String.downcase(id)}, groups), mapped to
the letters A, B, C and so on. The same id and seed always give the same group, whatever
the row order. A hash split is only approximately balanced: small lists can be far from
even. :erlang.phash2/2 is the Erlang term hash.
Summary
Functions
Assign every row to a group. Returns a map with :ids, :groups (the letters),
:seed, :assigned (rows with their :group, in input order), :by_group and
:by_segment.
The group letter of an id for a seed and a number of groups (2 to 26).
Parse the CSV text into a list of rows.
Render the report as text.
The assignment as CSV text: id,segment,group, in input order.
Types
@type row() :: %{ id: String.t(), key: String.t(), segment: String.t(), row: pos_integer() }
Functions
Assign every row to a group. Returns a map with :ids, :groups (the letters),
:seed, :assigned (rows with their :group, in input order), :by_group and
:by_segment.
The group letter of an id for a seed and a number of groups (2 to 26).
Parse the CSV text into a list of rows.
Render the report as text.
The assignment as CSV text: id,segment,group, in input order.