Data · Data Formats
up to +100 XP
Stop 6.5 · Data · 3 min

Data Formats

Master different data formats and their applications

Learning objectives:
  • Know the common data formats and when each is used (6.5.1)
  • Understand how data format relates to transformation and judge suitability (6.5.2)

Common data formats

JSON (JavaScript Object Notation)

Text format storing data as key-value pairs and lists. Lightweight and easy for programs to read, so widely used to send data between web applications and through APIs.

{"name": "Priya", "year": 13, "subjects": ["Digital", "Maths"]}

Text file

Plain text with no special structure (.txt). Simple and readable by almost any program, but the program must know how to interpret the contents. Good for notes and logs.

CSV (comma-separated values)

Plain text where each line is a record and values are separated by commas. The first line is often a header. Ideal for tables of data, spreadsheets and importing into pandas.

name,year,score
Priya,13,82
Tom,12,74

XML (eXtensible Markup Language)

Text format that stores data inside custom tags, in a hierarchy. Self-describing and good for complex, nested documents, but more verbose than JSON.

<student><name>Priya</name><year>13</year></student>

ASCII

A character encoding that represents characters as numbers, originally using 7 bits for 128 characters: English letters, digits, punctuation and control codes. Compact, but cannot represent most other languages or emoji.

UTF-8

A Unicode character encoding that can represent characters from almost every language and emoji, using 1 to 4 bytes per character. It is backwards-compatible with ASCII and is the standard encoding on the web.

Choosing a format

NeedSuitable format
Send data to or from a web APIJSON
A table to analyse or open in a spreadsheetCSV
A nested document with self-describing tagsXML
Simple notes or a logText file
Text in many languagesUTF-8 encoding
Basic English-only text with minimal storageASCII

Formats and transformation

The format affects how easily data can be transformed. CSV loads straight into a table for manipulation and analysis. JSON and XML keep nesting, so they may need flattening before analysis. Plain text needs to be split up before it can be processed. Using the wrong encoding can turn characters into nonsense.

Quick check · 10 questions

Check what stuck.

+10 XP each
Question 1

Question 1 of 10

Which format stores data as key-value pairs and is widely used by web APIs?

Question 2

Question 2 of 10

Which format stores each record on a line with values separated by commas?

Question 3

Question 3 of 10

Which format stores data inside custom tags in a hierarchy?

Question 4

Question 4 of 10

Which encoding can represent characters from almost every language and emoji?

Question 5

Question 5 of 10

Which encoding originally used 7 bits for 128 characters?

Question 6

Question 6 of 10

Which format is best for a table of data to open in a spreadsheet?

Question 7

Question 7 of 10

What is a drawback of a plain text file?

Question 8

Question 8 of 10

Why may JSON need extra work before analysis?

Question 9

Question 9 of 10 · Match the pairs

Match each data format to what it is.

CSV
JSON
XML
UTF-8
Question 10

Question 10 of 10 · Fill in the blanks

CSV stands for comma- values.