Skip to content

CSV Files

πŸŸ¨πŸ“Š Technique Card: Working with CSV Files (practical)

Big Idea: A CSV file is a way to store data in plain text β€” it stands for Comma-Separated Values.
Useful for: Saving data from surveys or projects, using data in Scratch, Python, or spreadsheets.


🧠 What’s a CSV?

A CSV is just a list of data stored in a text file, where each line is a row and each comma separates columns.

Here’s what a simple CSV might look like:

Name,Travel Type
Alice,Walk
Ben,Bike
Cleo,Car
Dan,Walk

πŸ‘† Each row is like one row in a spreadsheet. The commas act like the borders between columns.


βœ… Why Use CSV Files?

  • βœ… They work with lots of programs (Excel, Scratch extensions, Python, Google Sheets)
  • βœ… Easy to share and upload
  • βœ… Super simple to create by hand or from a spreadsheet
  • βœ… Great for storing survey results, project data, and changing values in code

πŸ§ͺ How to Make a CSV File

✍️ Method 1: With a Text Editor (like Notepad)

  1. Open Notepad (or any plain text editor).
  2. Type your data like this:
Food,Distance (km)
Apples,120
Bananas,6000
Carrots,50
  1. Save it as:
    food_miles.csv
    πŸ” Make sure it ends in .csv, and not .txt.

πŸ“Š Method 2: With Excel (or Google Sheets)

  1. Type your data into the spreadsheet like normal.
  2. Go to File β†’ Save As (or Download).
  3. Choose CSV (Comma delimited) (.csv) as the file type.
  4. Save!

πŸ“Ž Now your data is in a plain text format that other programs can understand.


πŸ’‘ Top Tips

  • Don’t use commas inside your data unless you really have to (it can confuse the file!)
  • Always check the first line – it’s the header and tells what each column means.
  • You can open CSV files in Excel, Google Sheets, Python, and some Scratch extensions (like the Data Importer).

πŸ” Try This!

Make a CSV with:

Name,How they get to school
Max,Walk
Tia,Bus
Alex,Bike

Open it in a spreadsheet and see the data appear in separate columns!
Then try changing the file in the text editor and reloading it.


πŸ”— Linked Cards


Watch the video