By the end of this lesson you will have:
BR1 Problem identification and gathering data
BR2 Data visualisation
A CSV file is a table saved as plain text: one header row of field names, then one record per row, with commas between the values.
id,year_group,survey_date,sleep_hours,study_hours,exercise_mins,plays_sport,mood
1,1,2027-01-31,9.2,0.3,50,False,okay
2,2,2027-01-30,6.8,1.4,66,True,lowsleep_hours.data/wellbeing.csv inside your Artefact folder.Collected data: run your survey with permission and without names, then export the answers as CSV.
Simulated data: write a Python program that generates realistic records. This one makes 200:
import csv
import random
from datetime import date, timedelta
random.seed(2027) # the same "random" data every run
start = date(2027, 1, 11)
with open("data/wellbeing.csv", "w", newline="") as f:
writer = csv.writer(f)
writer.writerow(["id", "year_group", "survey_date", "sleep_hours",
"study_hours", "exercise_mins", "plays_sport", "mood"])
for i in range(1, 201): # 200 records
year = random.randint(1, 6)
sleep = round(random.uniform(5.0, 9.5), 1)
study = round(random.uniform(0.0, 4.0), 1)
sport = random.random() < 0.5
exercise = random.randint(30, 120) if sport else random.randint(0, 60)
mood = random.choice(["good", "okay", "low"])
day = start + timedelta(days=random.randint(0, 27))
writer.writerow([i, year, day.isoformat(), sleep, study,
exercise, sport, mood])Keep the values realistic: sleep between 5 and 9.5 hours, not 0 or 20. random.seed(2027) gives the same data every run, which makes testing easier.
You're previewing this lesson. Get full access to this lesson and hundreds more — each one ready to teach, with interactive activities, printable resources and pupil progress tracking built in.