- 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
| Need | Suitable format |
|---|---|
| Send data to or from a web API | JSON |
| A table to analyse or open in a spreadsheet | CSV |
| A nested document with self-describing tags | XML |
| Simple notes or a log | Text file |
| Text in many languages | UTF-8 encoding |
| Basic English-only text with minimal storage | ASCII |
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.