Data Cleaning Exercises

Task: the rules
Input
  contacts(id, email) — text. id is unique. Emails are ASCII and always present.

Rules (this fictional system's declared policy)
  email: remove ASCII whitespace (space, tab, CR, LF) at both ends, then lowercase the whole address.
  Do not remove dots, plus tags or anything else; do not merge contacts. Running the rule twice changes nothing.

Output (row order does not matter)
  clean(id text, email text)

Tab inserts spaces. Press Escape, then Tab, to move focus out of the editor.

Input: contacts, rows 1 to 12 of 12
#idstringemailstring
1c2e40⇥s.am@Shop.Example.net· (raw value "\ts.am@Shop.Example.net ")
2co4rf··carol_99@MAIL.example.org·· (raw value " carol_99@MAIL.example.org ")
3cf5coSam+offers@example.COM
4c3vyo··carol_99@Example.com·· (raw value " carol_99@Example.com ")
5cgbcs⇥bob@example.com⇥ (raw value "\tbob@example.com\t")
6cmnxs··Sam+offers@Shop.Example.net·· (raw value " Sam+offers@Shop.Example.net ")
7crnsn·s.am@example.COM· (raw value " s.am@example.COM ")
8c8m37··sam+offers@mail.example.org·⇥ (raw value " sam+offers@mail.example.org \t")
9c7og7··s.am@MAIL.example.org·· (raw value " s.am@MAIL.example.org ")
10cghwl·⇥carol_99@MAIL.example.org·⇥ (raw value " \tcarol_99@MAIL.example.org \t")
11c80if·Ann.Lee@Example.com·· (raw value " Ann.Lee@Example.com ")
12c942ldan+news+2026@example.com

Run preview · in your browser, not a grade

Loading the preview runtime…

Check answer · graded on an isolated server, including hidden datasets

Your code runs in a locked-down machine with no network, on the visible data and on hidden datasets that follow the same rules.

Learn from this exercise

A worked solution becomes available after your first check or once you've used every hint.

AI tutor · may be wrong; the grader decides

SQL · DuckDB 1.5.1Preview runtime loadingNot saved yet · sign in to save to your account