File Handling (OCR GCSE Computer Science): Flashcards
📚Flashcards
Practise the cards
12 cards from this deck
ShowHide
Practise the cards
12 cards from this deck
Purpose of file handling
Purpose of file handling
Store, retrieve & update data on disk
Four key file operations
Four key file operations
Open, read, write, close
Must do this before reading/writing a file
Must do this before reading/writing a file
Open the file
Mode to open file for extracting data
Mode to open file for extracting data
Reading mode (read)
Mode to open file to create/modify it
Mode to open file to create/modify it
Writing mode (write)
Mode to add data to existing file without overwriting
Mode to add data to existing file without overwriting
Append mode
What reading a file means
What reading a file means
Extracting data from it
How files are typically read
How files are typically read
Line by line or in chunks
Effect of write mode on existing file contents
Effect of write mode on existing file contents
May be overwritten (unless append mode)
Why close a file after use
Why close a file after use
Free system resources & save changes
Python syntax to open file for reading
Python syntax to open file for reading
open("file.txt", "r")
Python syntax to open file for writing
Python syntax to open file for writing
open("file.txt", "w")
