1
00:00:05,280 --> 00:00:08,960
What is a text file?
That may seem a strange question: 

2
00:00:08,960 --> 00:00:14,320
a text file holds text – that's obvious.
But what does "text" mean? 

3
00:00:14,320 --> 00:00:17,648
A good definition is that a 
text file is "human readable". 

4
00:00:17,648 --> 00:00:23,520
You can open a text file in an editor – maybe 
notepad, on Windows, or TextEdit, on a Mac – 

5
00:00:23,520 --> 00:00:28,983
and you'll be able to read the contents.
All our Python .py files are text files. 

6
00:00:29,040 --> 00:00:34,160
We can read the contents in our IDE's editor.
A text file might also store HTML – 

7
00:00:34,160 --> 00:00:38,454
the contents that are displayed by 
your browser, when you visit a website. 

8
00:00:40,800 --> 00:00:44,320
For example, this is a very simple HTML document. 

9
00:00:44,320 --> 00:00:49,226
It might not make much sense, unless 
you understand HTML, but it is readable. 

10
00:00:51,920 --> 00:00:57,040
Storing data in text files is very convenient, 
because text files are easy to edit. 

11
00:00:57,040 --> 00:01:01,920
If we wanted to change the title, in the HTML 
document on the previous slide, we can open it 

12
00:01:01,920 --> 00:01:08,560
in our editor, make the change, and save the file.
Binary file formats are much harder to work with. 

13
00:01:08,560 --> 00:01:13,360
For example, editing video files requires 
special software – which can cost hundreds, 

14
00:01:13,360 --> 00:01:17,280
or thousands, of dollars.
Editing audio files also needs 

15
00:01:17,280 --> 00:01:22,673
you to install audio editing software, such as 
Audacity (which I mention because it's free). 

16
00:01:25,120 --> 00:01:27,600
Binary file formats are much harder to work with, 

17
00:01:27,600 --> 00:01:30,495
and you have to understand the 
binary format that was used, 

18
00:01:30,495 --> 00:01:35,610
before you can make sense of the contents.
Text files can be opened in any text editor. 

19
00:01:38,240 --> 00:01:43,200
Text files can be used to store plain text. 
The first text file that we'll work with, 

20
00:01:43,200 --> 00:01:49,543
in the next video, will contain the text of a poem.
But text files can also be used to store data. 

21
00:01:49,543 --> 00:01:53,328
There are many ways to store 
data in text files, including: 

22
00:01:53,440 --> 00:01:56,729
JSON – a data format derived from Javascript. 

23
00:01:56,960 --> 00:02:03,035
XML (and similar formats such as SSML).
CSV – Comma Separated Values. 

24
00:02:03,440 --> 00:02:07,840
Pickle files – a Python-specific 
way to serialise data. 

25
00:02:09,919 --> 00:02:15,362
We won't look at XML in this section, but we 
will be seeing examples of JSON and CSV files. 

26
00:02:15,600 --> 00:02:20,058
And, because this is a Python course, 
we'll be looking at Python's pickle format. 

27
00:02:20,400 --> 00:02:27,520
We'll get started by reading and writing 
plain text files. See you in the next video.

