Read files (Edexcel GCSE Computer Science): Flashcards
📚Flashcards
Practise the cards
13 cards from this deck
ShowHide
Practise the cards
13 cards from this deck
Why must data be read into memory?
Why must data be read into memory?
Programs can only process data in RAM, not directly from storage
Memory (RAM) vs Storage characteristics
Memory (RAM) vs Storage characteristics
Memory: fast & temporary. Storage: permanent but can't use directly
What is a record in a file?
What is a record in a file?
Information about one item, stored on a separate line
What are fields in a record?
What are fields in a record?
Different pieces of information separated by commas within a record
What CSV stands for
What CSV stands for
Comma Separated Values
Purpose of carriage return & line feed
Purpose of carriage return & line feed
Invisible characters showing where lines end/begin
What strip() function does
What strip() function does
Removes invisible carriage return & line feed from line ends
Meaning of 'r' in open(filename, 'r')
Meaning of 'r' in open(filename, 'r')
Read mode (read-only)
What split(',') does to a line
What split(',') does to a line
Breaks line at commas, creates a list of separate pieces
Data type of all items read from text file
Data type of all items read from text file
String (text) - even numbers
Why convert data types after reading files
Why convert data types after reading files
Everything is initially string; need correct type for calculations
Purpose of file.close()
Purpose of file.close()
Closes file when finished to free system resources
File mode for reading (not writing)
File mode for reading (not writing)
Use 'r' not 'w' (w would overwrite file)
