Storage : File Processing

Two common methods of processing saved files are sorting and merging. These are often used by batch processing systems which store data as records in files. For example a file might contain records about people who are employed by a company. There would be one record per employee.

Sorting

Sorting is arranging the records in a file into a particular order, such as by employee number.

Merging

Merging is combining the contents of two files into one file. The simplest method of merging two files together is to just take the contents of one file and add them to the end of the other. This is known as appending :

If the records in a file must be kept in a particular order (a sequential file) then the merge process is more complex. To carry out a merge the algorithm shown in this flowchart must be followed :

The results of the merge are also shown in the above diagram. Note that unlike a simple append, this more sophisticated merge has produced a new file that maintains the required order. The records in two files that are to be merged must have the same record structure.

GCSE ICT Companion 04 - (C) P Meakin 2004