0984

File Handling

Programming · 4 question types

Exam Frequency Analysis

Past paper frequency (2018 to 2024)

This topic accounts for approximately 3% of your exam marks.

stable
Rare
Stable3%

OPENFILE, READFILE, WRITEFILE, CLOSEFILE pseudocode operations appear occasionally.

CIE pseudocode uses a small set of dedicated keywords for file operations.

OperationPseudocodePython equivalent
Open for a given modeOPENFILE "filename.txt" FOR <mode>file = open("filename.txt", "r") (or "w")
Read one lineREADFILE "filename.txt", LineVariableline = file.readline()
Write one lineWRITEFILE "filename.txt", TextToWritefile.write("text\n")
Close the fileCLOSEFILE "filename.txt"file.close()

The CIE file commands always include the filename so the operation knows which file it is acting on.