← VCE Software Development U3O1

Delimited (CSV) files: structure

A text file with one record per line, fields split by a delimiter such as a comma, and an optional header line of field names. Text containing commas goes in quotes.

Understanding Delimited (CSV) files: structure in VCE Software Development U3O1

What it does: The quotes tell the program that the comma inside the name is part of the text, so this line still has three fields. A CSV-style file can use another delimiter character, and the program reading it must split on that same character. A header is the first line and lists the field names, such as name,age,city. It is not a data record. CSV usually uses a comma, but other delimiters such as semicolons, tabs or pipes can be used as long as every line uses the same one. Splitting on each comma gives Mia, 17 and Perth, which are 3 separate fields.

Common mistakes: The double comma creates an extra empty field, so this record has 4 fields while the header has 3. It should be Liam,16,Blue. The header uses commas as the delimiter, so every record must too. Semicolons would make the whole line read as one field. It should be 1,Ava,90.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 98–113) and word search (Modules 72–113).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
In a CSV file, how is each record stored?
One record per lineOne record per field
Matches
Nguyen, Ava,7,Red
↓
The comma inside the name is not quoted, so it is read as a delimiter and the line splits into four fields instead of three. Fix: "Nguyen, Ava",7,Red
Applying
Meanings
Term
CSV
Meaning
A text file with one record per line, fields split by a delimiter such as a comma, and an optional header line of field names. Text containing commas goes in quotes.
Practice
name,year,house,points
Testing
Gaps
fields = line.(",")
Check Answer
Spots
2Ava,15,Red
3Liam,16,,Blue

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Zebra' badge — Pattern Matcher, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. In a CSV file, how is each record stored?
A. One record per line ✓
B. One record per field
Each line of a CSV file is one record. The fields inside that record are separated by a delimiter.
2. Which line is a valid CSV record with three fields?
A. Ava 16 Melbourne,
B. Ava,16,Melbourne ✓
A comma is the delimiter that separates the fields. Spaces alone do not mark the field boundaries in a comma-delimited file.
3. What is the job of the delimiter character in a CSV file?
A. It separates one field from the next ✓
B. It marks the end of the whole file
The delimiter (usually a comma) sits between fields on the same line so a program knows where each field starts and ends.
4. What does the optional header row contain?
A. The total number of records
B. The names of the fields ✓
A header is the first line and lists the field names, such as name,age,city. It is not a data record.
5. A CSV file has a header row plus 5 lines of data. How many records does it store?
A. 5 records ✓
B. 6 records
The header row only names the fields. The 5 data lines are the records.

Match the Pairs

name,year,house → A header row: the first line lists the field names, separated by commas
Ava,7,Red → One record on a single line, with three fields separated by commas
Text that contains a comma is wrapped in double quotes so the comma is not treated as a delimiter → "Nguyen, Ava",7,Red
A delimiter other than a comma, such as a semicolon, can separate the fields in a delimited file → Ava;7;Red
Nguyen, Ava,7,Red → The comma inside the name is not quoted, so it is read as a delimiter and the line splits into four fields instead of three. Fix: "Nguyen, Ava",7,Red
name,year,house Ava,7,Red → The header and the record are on the same line. Each record must be on its own line, so the header and the record need a line break between them.

Key Term

CSV
A text file with one record per line, fields split by a delimiter such as a comma, and an optional header line of field names. Text containing commas goes in quotes.

Fill in the Blanks

1. fields = line.split(",")
Hint: Type the string method that breaks one line into a list of fields at the delimiter
2. delimiter = ";" fields = line.split(delimiter)
Hint: Type the variable name that holds the field separator character
3. header = lines[0] records = lines[1:]
Hint: Type the index of the first line, which holds the field names
4. recordCount = len(lines) - 1
Hint: Type the operator that leaves out the header line from the count of records
5. line = ",".join(fields)
Hint: Type the string method that joins a list of fields into one delimited line

Spot the Error

Question 1
A name,age,house
B Ava,15,Red
C Liam,16,,Blue
Line C — The double comma creates an extra empty field, so this record has 4 fields while the header has 3. It should be Liam,16,Blue.
Question 2
A id,name,score
B 1;Ava;90
C 2,Liam,85
Line B — The header uses commas as the delimiter, so every record must too. Semicolons would make the whole line read as one field. It should be 1,Ava,90.
Question 3
A item,price,note
B Pen,2.5,"blue, fine tip"
C Book,12,red, hardcover
Line C — The note contains a comma, so it must be wrapped in double quotes. Without them the line splits into 4 fields. It should be Book,12,"red, hardcover".
Question 4
A name,age,year
B Zoe,14,9
C Leo,15
D Mia,13,8
Line C — The header has 3 fields, so every record needs 3 fields. This record is missing the year. It should be Leo,15,10.
Question 5
A name,age
B Ava,15,Perth
C Liam,16,Hobart
Line A — The header row must list a name for every field in the records. The records have 3 fields but the header names only 2. It should be name,age,city.

Student with a class code? Join your class →