Skip to content
ExamSpine

B2.5 File processing: notes and practice

B2.5 covers working with files: opening, reading line by line, writing and appending, parsing CSV data into lists and handling errors such as a missing file.

Paper 2SL and HL0 practice questions

What you need to know

Our summary of the topic in our own words, not the IB guide.

  • Open a file for reading, read its contents, and close it properly
  • Read a file line by line and process each line
  • Write and append data to a file, and explain the difference between write and append mode
  • Parse a delimited text file such as CSV into a list or a two-dimensional structure
  • Convert text read from a file into the right data type before using it
  • Handle file errors such as a missing file or a permission problem
  • Explain the difference between an absolute and a relative file path

Practice questions

Questions for this topic are being written. The other topics below already have some.

Exam tips for B2.5

  • Remember that text read from a file is a string. Convert it before doing arithmetic.
  • Know that write mode replaces the file and append mode adds to the end.
  • Close files, or use the language feature that closes them for you.

Updated 24 October 2026. Topic codes are used as labels. Everything on this page is written by ExamSpine and is not endorsed by the IB.