Module 5 · Data that arrives dirty

Text that looks identical and is not

In this lesson

  • 9 min read
  • 6 reading sections
  • Knowledge check
  • Lesson 5 of 12 in this chapter

This chapter’s goalLoad an exported CSV with mixed encodings, ambiguous dates and duplicate rows into a typed, deduplicated table by re-runnable query with every dropped row counted, decide and document what each missing value means, and produce a feature table for a model in which no column knows anything that happened after its row’s timestamp.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 7Free · no account needed
Lesson steps

The GROUP BY that shows the same city twice

SQL
SELECT city, count(*) FROM raw_payments GROUP BY city ORDER BY city;
-- Lagos      4,120
-- Lagos      2,893

Two rows, identical on screen. They differ in a character you cannot see. This lesson is the short list of ways two strings look the same and compare unequal, and the one-line fix for each.

Whitespace that trim() does not remove

trim() removes ordinary spaces from both ends. It does not remove a tab, a non-breaking space (the character a web page uses to stop a line wrapping, code point 160), or a zero-width space (code point 8203, which copy-and-paste from some apps inserts). All three are invisible in every tool you will look at the data with.

SQL
SELECT city, length(city), encode(city::bytea, 'hex')
FROM raw_payments
GROUP BY city;

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the Building Apps with AI exam.

Stuck on something?Ask Divya, your AI tutor

How to cite: Addaly (2026) ‘Text that looks identical and is not’, in Data, SQL and Getting to the Answer. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/data-and-sql/strings-trim-case-and-unicode (Accessed: 29 November 2026).