Data Cleaning Exercises

Module 2

Import correctly

CSV quoting, headers, encoding, delimiters, explicit types and file provenance.
  1. Import everything as text first

    Load a CSV without letting the tool guess types, so leading zeros, "NA" strings and odd dates survive until a rule decides what they mean. · 9 min

  2. Encodings and mojibake

    Recognise wrong-encoding damage and fix it at import by declaring the encoding. · 7 min

  3. Delimiters and quotes

    Read files whose values contain separators, quotes or line breaks without shifting columns. · 6 min

  4. Explicit types at import

    Read raw files as text and convert each column deliberately afterwards. · 6 min

Module 2 quiz

Practice questions: choose an answer and check it to see the explanation. Nothing here is timed or graded.

  1. 1. A German export is read with the default comma delimiter and every row lands in one column. What is the likely cause?
  2. 2. A UTF-8 file containing "José" is read as Windows-1252. What appears?
  3. 3. How should a raw CSV be loaded so that no value changes before your rules run?
  4. 4. A CSV field is "Smith, Jane" with quotes. A script splits each line on commas. What happens?
  5. 5. Why record the file name, delivery date and row count of each import?
  6. 6. A date column arrives as Excel serial numbers (45292). What is the safe approach?