File Handling

When programming, it is useful to be able to work with files and data that is stored out with the code in an external file. This can be very useful when you want to import a large amount of information into the program rather than having to type it in manually. This can also be beneficial if you would like to export data from a program so it can be used again in the future.

Read From File

To Read from a sequential file means to take the data from the file and store it in a variable, array or record for future use in the program.

Before you can read from a file you have to open the file. Once the file is open it is possible to create code that will read specific data from the file.

Example in Python

Example in Pseudocode

Write to File

When you write to a file you are often sending the values held in variables, arrays and records out of the program for storage within a sequential file.

Example in Python

Example in Pseudocode