Dataset file formats: CSV, XLSX, JSON and XML

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Dataset file formats: CSV, XLSX, JSON and XML

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which file format stores data as plain text with values separated by commas?
A CSV
B XLSX
2. Which file format is an Excel workbook that can hold several sheets, formulas and formatting?
A XLSX
B CSV
3. Which snippet is JSON?
A <student><name>Ava</name></student>
B {"name": "Ava", "mark": 88}
4. Which snippet is XML?
A Name,Mark Ava,88
B <student><name>Ava</name></student>
5. You want to open a downloaded dataset in a spreadsheet and keep it simple. Which format is the better choice?
A CSV or XLSX
B XML only

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1results.csv AA plain text file where each row is a record and the values in a row are separated by commas
2results.xlsx B<mark>88</mark>
3JSON stores data as key and value pairs inside curly braces CAn Excel workbook file that stores data in sheets and can also keep formulas and cell formatting
4XML stores each value between opening and closing tags DCSV is plain text and only stores values, so formulas and formatting are lost. XLSX should be chosen to keep them.
5Choosing a CSV file because you need to keep formulas and cell colours E{"name": "Ava", "mark": 88}
6Name,Maths,English;Ava,88,74;Liam,65,70 FA CSV file uses commas between values and a new line for each record, not semicolons between records.

Definitions

file format

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
Plain text, comma separated: data.___
2.
Excel workbook with sheets: marks.____
3.
Key-value data for web apps: feed.____
4.
<student><name>Ava</____></student>
5.
<?___ version="1.0"?>

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A Name,Maths,English
B Ava,88,74
C Liam,65,70
D Mia,95
Question 2
A {
B "name": "Ava",
C "maths": 88,
D "english": 74,
E }
Question 3
A <student>
B <name>Ava</Name>
C <maths>88</maths>
D </student>
Question 4
A import csv
B f = open('marks.csv')
C rows = json.load(f)
D for r in rows:
E print(r)
Question 5
A [
B {"id": 1, "mark": 88},
C {id: 2, "mark": 65}
D ]

Answer Key

Dataset file formats: CSV, XLSX, JSON and XML
Section A: Quick Questions
Q1
A — CSV
Q2
A — XLSX
Q3
B — {"name": "Ava", "mark": 88}
Q4
B — <student><name>Ava</name></student>
Q5
A — CSV or XLSX
Section B: Match the Pairs
Q1
results.csv → A plain text file where each row is a record and the values in a row are separated by commas
Q2
results.xlsx → An Excel workbook file that stores data in sheets and can also keep formulas and cell formatting
Q3
JSON stores data as key and value pairs inside curly braces → {"name": "Ava", "mark": 88}
Q4
XML stores each value between opening and closing tags → <mark>88</mark>
Q5
Choosing a CSV file because you need to keep formulas and cell colours → CSV is plain text and only stores values, so formulas and formatting are lost. XLSX should be chosen to keep them.
Q6
Name,Maths,English;Ava,88,74;Liam,65,70 → A CSV file uses commas between values and a new line for each record, not semicolons between records.
Section C: Definitions
Q1
file format — The way a dataset's data is structured and stored in a file, such as CSV, XLSX, JSON or XML. Choose the format that suits the software you will open it in.
Section D: Fill in the Blanks
Q1
Plain text, comma separated: data.csv
Q2
Excel workbook with sheets: marks.xlsx
Q3
Key-value data for web apps: feed.json
Q4
<student><name>Ava</name></student>
Q5
<?xml version="1.0"?>
Section E: Spot the Error
Q1
D — In a CSV file every row needs the same number of comma-separated fields as the header. This row is missing the English mark and should be Mia,95,89.
Q2
D — JSON does not allow a trailing comma after the last item in an object. The line should be "english": 74 with no comma.
Q3
B — XML tags are case-sensitive, so the closing tag must match the opening tag exactly. It should be </name>.
Q4
C — marks.csv is a CSV file, so it must be read with a CSV reader. The line should be rows = csv.reader(f), because json.load only reads JSON.
Q5
C — In JSON every key must be written in double quotes. The line should be {"id": 2, "mark": 65}.