Data cleanup and merging

How to Merge Adjacent Customer Duplicates by Email or external_id

2026-06-20
Task

Several adjacent rows may belong to the same customer. Merge them by a non-empty email, or by external_id in a separate configuration, while retaining different names and other values.

Short answer

Create the target email column from email_raw, apply only AnyTrim spaces at edges, and enable similar-row merging by the current column with exact matching and separator ;. If the goal is to collect every repeated key, sort the input by that key first; otherwise, only repeats that are already adjacent will merge.

How to Configure It in Eofferix

  1. Add or open the target email column, select email_raw as its source, and keep a single transformation: AnyTrim spaces at edges. The column names belong only to this example; no universal lowercase conversion is applied.

    Opening the target email column settings in the Eofferix table editor
    The email column reads email_raw and removes only the surrounding whitespace.
  2. In the column’s Additional settings, enable row-structure changes and select the mode that merges similar rows.

  3. Choose the current column as the merge key, leave the comparison value empty, select exact matching, and enter ; as the separator. Do not rely on a space after it: the setting is normalized, so the actual output is value1;value2.

    Settings for merging adjacent rows by the current email column
    Merge mode uses exact matching and the semicolon separator without a space.
  4. If all repeated keys must be collected, stably sort the table so equal keys are consecutive before running the transformation; if input order must be preserved, expect only adjacent repeats to merge. Then inspect the result. To merge by external_id, configure a separate run with that column as the key; one merge mode does not mean “email OR external_id.”

    Merged adjacent customer rows showing email and name variants
    Adjacent keys matched case-insensitively; distinct values were joined with a semicolon. The deliberately unsorted non-adjacent control and blank keys stayed separate.
Important. email_raw, email, external_id, and the shown addresses are only an example. Merging is a single pass over adjacent rows with the same non-empty key. Exact key comparison is case-insensitive, but uniqueness of emitted values is case-sensitive: Anna@Example.test and anna@example.test form one group, yet both spellings appear in its output.

Expected Result

Adjacent source rowsResultWhy
Anna@Example.test / Anna Petrova + anna@example.test / Anna P.Anna@Example.test;anna@example.test / Anna Petrova;Anna P.After trimming, the keys match case-insensitively; differently cased emails and different names are retained with ;.
peter@example.test / Peter + peter@example.test / Peter P.peter@example.test / Peter;Peter P.A fully identical email is emitted once, while the two different names are joined.
anna@example.test, then ivan@example.test, then anna@example.test againthree rowsThis control is deliberately unsorted: the later Anna row cannot rejoin a closed group. After sorting by email, it would become adjacent and merge.
blank email / Customer A + blank email / Customer Btwo rowsBlank keys never count as a match.
C-1001 / Anna + C-1001 / Anna P., using external_id as keyC-1001 / Anna;Anna P.A separate external_id configuration merges an adjacent group in the same way.
abc-1 + ABC-1, using external_id as keyone groupExact key comparison is case-insensitive; use this key only if that is safe for your identifiers.
one key with different phone numbers or namesall unique values joined with ;The service does not choose a winner or determine which conflicting value is correct.

Checks Before Export

  • The key column has only AnyTrim spaces at edges; there is no automatic lowercase conversion of email values.
  • If every repeated key must be merged, rows are stably sorted by the selected key before processing because only adjacent matches are merged.
  • The mode uses the current column, exact matching, an empty comparison value, and separator ;.
  • Anna@Example.test and anna@example.test become one row whose email is Anna@Example.test;anna@example.test.
  • A deliberately unsorted control keeps a non-adjacent repeat separate; after sorting by the key, that repeat would join its group.
  • Two blank-key rows remain two rows, and conflicting values are reviewed before export.

Limits of This Example

  • This is adjacent-group merging, not global deduplication of the entire file. A stable sort by the key is required when all repeats must be brought together.
  • A run has one merge key. An email OR external_id policy requires a deliberately prepared combined key or two controlled stages.
  • A blank key does not merge rows, so records without an email remain separate.
  • Exact means equality of the whole trimmed value, compared case-insensitively; it is not a substring search. The SMTP standard requires the mailbox local-part to be treated as case-sensitive, so use this email key only when your data policy considers case variants identical; see RFC 5321, section 2.4.
  • Unique non-empty values in each column are joined with the actual separator ;, without a space. When values conflict, Eofferix preserves the alternatives but does not resolve them.

Process data faster with Eofferix

Create a free account to automate catalogs and price lists around your own rules.

Sign up