Processing Data Records
This is so common!
In lots of programming tasks we need to be able to process records sequentially. The records can be in files, databases, entered live, or even from data on a distant server that was brought to your program with AJAX.
A record is like a row in a spreadsheet. Here's an example of an employee record:
1000, "John", "Smith", "Engineer", "555-1234"
The record has discrete pieces of data that have been separated with commas. Each of the pieces of datum in the record is called a field.
In data processing we sometimes call the commas a delineator.
A Record Set (a file) is a bunch of records like the one above. The number of records in a record set can vary from just a few to many millions.
Records can exist in many ways and you will learn lots of ways in your coming semesters. The most important way that organizations store data records these days are in databases. This is why there are several semesters of database courses in our programming degree.
One step at a time.
Here's how it works. When you are writing a program that needs to process records you will create a variable that stores all the records you need. For example, it might be named "records" as in the following example:
- You then use a system function that starts with "open" to make the data available for use in your application. The particular one to use for any given record set will be documented in the lab or project file. After this function has been run your program will be ready to read the first record in the set.
records = openSampleDataRecords();
- A function to read the next record. This makes the next record available if there are any more to be read. If there aren't anymore records then the function returns
false. If there are more records then the function returns
true. This is typically called as the loop conditional.
- Let's see how this all works
Available Record Sets¶
Here is a list of the available records sets for this unit. We'll be using these for labs, projects, and demos for this unit. Each one is a link to more details about the set.
Student Exam Records¶
Student Enrollment Records¶
Inventory Items Records¶
Employee Payroll Records¶
Record Processing Demo¶
Here's a demo of how to loop through one of these record sets.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
** Click me to run
Note: Refresh the page to return to the course content
- Lab03: Record Set Processing
- Lab04: A Simple Start with Student Enrollment Records