One sale, four shapes
Four systems all need the same shop sale: number 12, the north shop, a cup of tea.
One keeps it as a note. One keeps it as a row of values. Two keep it with labels in a tree.
All four are plain text you can open and read. They differ in how much structure they hold.
Key words
| Word | What it means | Example |
|---|---|---|
| Format | The way data is laid out in a file. | .csv |
| Text file | A file of plain characters with no set layout. | notes.txt |
| CSV | Comma separated values: one record per line, fields split by commas. | 12,north,tea |
| JSON | Text in labelled pairs inside braces, used to send data between programs. | {"id": 12} |
| XML | Text in nested tags that label each piece of data. | <id>12</id> |
| Delimiter | A mark that separates one field from the next. | A comma |
The cells students fill in are left blank in this preview.
By the end of this lesson
Note
I can recognise four common file layouts and say when each is used.
Starter: what you already know
Have a go
Starter: what you already know
3 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.
Text files and CSV
A text file is plain characters. It has no rules about layout, so it suits notes, logs and readme files. Any device can open it.
A CSV file has one record on each line. A delimiter, a comma, separates the fields. Spreadsheets swap data this way. It is small and simple, but it has no types and no labels beyond a header line.
JSON and XML
JSON stores labelled pairs inside braces. It can nest one item inside another, and it is the usual shape for data sent between web programs.
XML wraps each piece of data in tags that name it. It nests deeply and describes itself, but it is longer to write.
Both are text, and both hold structure that CSV cannot.
The same sale in four formats
| Format | How sale 12 looks |
|---|---|
| Text file | Sale 12 at the north shop: tea. |
| CSV | 12,north,tea |
| JSON | {"id": 12, "shop": "north", "item": "tea"} |
| XML | <sale><id>12</id><shop>north</shop><item>tea</item></sale> |
The cells students fill in are left blank in this preview.
Check: which format?
Have a go
Check: which format?
3 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.