Module 6: Cleaning and Managing CSV and Excel Data
6.1 What You Will Learn
At the end of this module, you should be able to:
- Explain what data cleaning means.
- Identify incorrect and missing information.
- Find and remove duplicate records.
- Correct spelling mistakes and inconsistent formatting.
- Identify common CSV file problems.
- Prepare spreadsheet data for analysis.
6.2 What Is Data Cleaning?
Data cleaning is the process of finding and correcting mistakes,
removing unnecessary information and fixing problems in a dataset.
Imagine your teacher gives you a list of 50 students. Some names appear
twice, some students have no examination scores, and some names are
misspelled.
If you use this information without correcting the mistakes, your results
may be wrong.
Data cleaning helps you make information accurate, complete and ready
for use.
Example of Unclean Data
| Name |
Age |
Score |
| David |
13 |
85 |
| Mary |
12 |
90 |
| David |
13 |
85 |
| John |
13 |
|
| grace |
12 |
95 |
Can you identify the problems?
- David appears twice.
- John's examination score is missing.
- Grace's name begins with a small letter while other names begin with capital letters.
These are examples of data quality problems that should be checked
before analysing the information.
6.3 Why Is Data Cleaning Important?
Data cleaning is important because incorrect information can lead to
incorrect decisions.
Here are some reasons why we clean data:
- Improves accuracy: Helps correct wrong information.
- Removes duplication: Prevents the same record from being counted more than once.
- Improves organisation: Makes information easier to read and understand.
- Saves time: Reduces problems during data analysis.
- Supports better decisions: Helps people make decisions using more reliable information.
6.4 Understanding Missing Data
Missing data occurs when important information is not available in a
particular cell or record.
For example, a student record may contain a name and age but no examination
score.
Example
| Student |
Age |
Score |
| David |
13 |
85 |
| Mary |
12 |
90 |
| John |
13 |
|
| Grace |
12 |
95 |
John's score is missing. Before using this information, you should find
out why the score is missing.
How Can Missing Data Be Handled?
- Check the original record to find the correct information.
- Ask the person responsible for the information if necessary.
- Leave the cell blank if the information is genuinely unavailable.
- Use a clear label such as Not Available when appropriate.
- Remove a record only when there is a valid reason and it is safe to do so.
Important: Never invent information to fill an empty cell.
A guess can make your data inaccurate.
6.5 Finding and Removing Duplicate Records
A duplicate record is information that appears more than once when it
should only appear once.
Imagine a shop owner records the same customer's payment twice.
If both records are counted, the shop may believe the customer paid
more money than they actually did.
Example of Duplicate Records
| Customer |
Product |
Amount (โฆ) |
| Samuel |
Rice |
5000 |
| Esther |
Beans |
3500 |
| Samuel |
Rice |
5000 |
The first and third records look exactly the same. If the third record
was entered by mistake, it is a duplicate.
How to Remove Duplicates in Microsoft Excel
- Open your spreadsheet.
- Select the data table.
- Go to the Data tab.
- Click Remove Duplicates.
- Select the columns Excel should check.
- Click OK.
- Excel will report how many duplicate values were removed.
Important: Two records with the same name are not always
duplicates. For example, two different students may be named David.
Check the relevant details before deleting any record.
6.6 Correcting Spelling Mistakes and Inconsistent Text
Sometimes, the same information may be entered in different ways.
This is called inconsistent data.
Example
| Original Information |
Corrected Information |
| ibadan |
Ibadan |
| LAGOS |
Lagos |
| computer studies |
Computer Studies |
| Mathematic |
Mathematics |
Notice that the corrected information follows a consistent style.
How to Correct Information
- Find the cell containing the incorrect information.
- Click the cell.
- Correct the spelling or formatting.
- Press Enter to save the change.
- Check other records for similar mistakes.
6.7 Removing Unwanted Spaces
Sometimes, people accidentally add spaces before or after names and other
information.
For example:
- Correct: David
- Incorrect: David
- Incorrect: David
These unwanted spaces can cause problems when sorting, comparing or
searching for information.
In Excel, you can use the TRIM function to remove unnecessary spaces
from text.
Example of the TRIM Function
=TRIM(A2)
If cell A2 contains a name with extra spaces, the TRIM function returns
a cleaner version of the text.
6.8 Understanding Common CSV Formatting Problems
CSV files are simple, but sometimes their information may not appear
correctly when opened in spreadsheet applications.
Here are some common problems:
- Everything appears in one column: The application may not recognise the comma separator.
- Strange symbols appear: The file may have an encoding problem.
- Leading zeros disappear: Numbers such as 00125 may be treated as ordinary numbers.
- Dates change format: The spreadsheet may interpret dates using different regional settings.
- Information appears in the wrong columns: The file may contain unexpected separators or incorrectly formatted text.
Example: Leading Zeros
Imagine a student has an identification number of 00125.
If Excel treats it as an ordinary number, it may display 125 instead.
This can be a problem because 00125 and 125 may represent different
identification numbers.
To prevent this, import the column as text when appropriate or format
the cells as Text before entering the information.
6.9 Checking Data Before Analysis
Before analysing a spreadsheet, it is important to check that the
information is complete and correctly organised.
Use this simple checklist:
- Are the column headings clear?
- Are there spelling mistakes?
- Are any important values missing?
- Are there duplicate records?
- Are dates and numbers displayed correctly?
- Are names and descriptions written consistently?
- Are all records arranged in the correct columns?
6.10 Practical Activity: Cleaning a Student Records File
Imagine your school administrator gives you the following student records.
Your task is to identify the mistakes and prepare the information for analysis.
Unclean Student Records
| Name |
Age |
Class |
Score |
| David |
13 |
JSS2 |
85 |
| Mary |
12 |
JSS1 |
90 |
| David |
13 |
JSS2 |
85 |
| john |
13 |
JSS2 |
|
| Grace |
12 |
JSS1 |
95 |
Complete the following tasks using Microsoft Excel or Google Sheets:
- Create a spreadsheet and enter the student records.
- Identify the duplicate record.
- Check the missing examination score.
- Correct the name john to John.
- Investigate the missing score instead of guessing it.
- Remove the duplicate only after confirming it is an accidental repeat.
- Check that all information is in the correct columns.
- Save the cleaned file as Clean Student Records.xlsx.
6.11 Best Practices for Managing Data
- Always keep an original copy of important data before making changes.
- Use clear column headings.
- Do not guess missing information.
- Check records before removing duplicates.
- Use consistent formats for dates, numbers and names.
- Save your work regularly.
- Protect private information and share files only with authorised people.
6.12 Important Terms to Remember
- Data Cleaning: Finding and correcting problems in a dataset.
- Missing Data: Information that is not available in a record.
- Duplicate Record: A record that appears more than once when it should not.
- Inconsistent Data: Information entered using different formats or styles.
- TRIM: An Excel function used to remove unnecessary spaces from text.
- Data Quality: How accurate, complete and consistent information is.
- Dataset: A collection of related information.
6.13 Module Summary
In this module, you learned that data cleaning is an important part of
working with CSV and Excel files. You discovered how to identify missing
information, remove accidental duplicates, correct spelling mistakes
and fix inconsistent formatting.
You also learned how to identify common CSV problems and check the quality
of your data before performing analysis.
Knowledge Check
- What is data cleaning?
- Why is data cleaning important?
- What is missing data?
- What is a duplicate record?
- Which Excel function can remove unnecessary spaces from text?
- Why should you check records before removing duplicates?
- What can happen when a CSV file is not separated correctly?
- Why should you keep an original copy of important data?
- What should you do when an examination score is missing?
- What does data quality mean?
Coming Up in Module 7
In the next module, you will learn how to use basic formulas and data
operations in Excel. You will discover how to calculate totals, averages,
counts, minimum values and maximum values using simple spreadsheet formulas.