Data analysis is the process of taking raw data and working with it to produce useful information in a meaningful format. It may involve operations such as transformations, filtering, sorting and grouping. To be successful as a data-centric language, eXPL must provide the tools to perform data analysis. This section provides three examples of eXPL analysing data, the first two simple, and the last more complex. The aim is to give some assurance eXPL is a practical language when it comes to working with data. For example, the last example has data taken from a spreadsheet which had empty cells indicating "no data available". You can see how eXPL handles incomplete data sets.
Numbering, Filtering and Formating
The AsiaTopTen application of tutorial5 selects the first 10 asian mega cites from a list of 35 mega cities, numbers them from 1 to 10 and formats the population numbers according to the locale. So this is what the data looks like going in:
The first value is a rank out of 35, followed by city, country, continent and population. This is the program:
integer count = 0;
template asia_top_ten (
city = Megacity,
country = Country,
population = Population.format);
These are the first two cities of the solution:
asia_top_ten(rank=2, city=Delhi, country=India, population=26,580,000)...
Here variable "count" is declared outside the asia_top_ten template so it is unaffected by backtracking.
The count variable controls what Asian cities are selected and doubles for setting the rank value. It is obvious
from the post increment (count++) that selection precedes any evaluation on the left hand side of the
? operator.
Note that population value produced by the built-in format function will vary according to locale, but eXPL provides a way to control what locale is used. This is covered in the section on scopes.
