Menu

1 / 2

Cleaning a messy contacts CSV in 5 steps (with a short pandas script)

DEV Community: datascience·Peter (The Trillium Company)·about 12 hours ago
#cWK76J7u
#devtodatascience#science#devto#dev#example
Reading 0:00
15s threshold

Most "messy CSV" problems in small businesses come down to the same five fixes. Here they are on a tiny example, with a short pandas script you can run yourself.

The example (synthetic data, made up for this post)

Before ( contacts_raw.csv ):

Name,Phone,Email,Signup Date,City " jane DOE ",(519) 555-0142,[email protected] ,2026/03/04,waterloo JANE DOE,519.555.0142,[email protected],04-03-2026,Waterloo Raj Patel,+1 416 555 0199,[email protected],March 7 2026,TORONTO ,,,, mei lin,5195550177,[email protected],2026-03-09, kitchener

Enter fullscreen mode

Exit fullscreen mode

After ( contacts_clean.csv ):

first_name,last_name,phone,email,signup_date,city Jane,Doe,+1-519-555-0142,[email protected],2026-03-04,Waterloo Raj,Patel,+1-416-555-0199,[email protected],2026-03-07,Toronto Mei,Lin,+1-519-555-0177,[email protected],2026-03-09,Kitchener

Enter fullscreen mode

Exit fullscreen mode

Five changes made the difference:

Trim and normalize case. Stray spaces and ALL CAPS break matching.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.