Pearson Edexcel GCSE Computer Science (1CP2)Specification point 6.4.2

Edexcel 1CP2 6.4.2: Reading and writing CSV files

The free BugBot lesson that teach this point, a robot to try it on, and the past-paper questions that test it.

What it covers

Everything a program stores in variables disappears when it stops. To keep data between runs, a program writes it to a file, and reads it back next time. Robots keep logs this way: every run, what happened, and how it went. In this lesson BugBot reads its run log from a file and adds to it.

  • The files on this page
  • Reading a file
  • Line by line
  • Writing a file
  • The whole file as a list of records
  • When files go wrong
Read the free lesson (15 min)

Or do it in the simulator, with tasks that mark themselves

Lessons that teach it

  1. F7.1 Reading and writing files Files and databases
    Open, read, write, append and close: a run log in a CSV file.

Try it on a robot

The task from F7.1 Reading and writing files, running here. Change the program and press Run.

Past paper questions on this

Real exam questions that test this, each worked through with a program you can run.

The specification is Edexcel's own document; this page says which of our lessons teach point 6.4.2 and is not endorsed by the board.