From array to data file
Filter data from a worksheet into an array, then write a Web page.
Filter data from a worksheet into an array, then write a Web page.
Frequencies are counts of things in different categories. For example, 417 people were asked to choose their favorite pet from a list of animals. Here's the data:
Bird | 71 |
Cat | 90 |
Dog | 144 |
Fish | 82 |
Llama | 30 |
There are five categories. The numbers are the counts of people who chose the animal.
People who write business programs, whether they're full-time programmers or not, spend much of their time on data analysis programs. Executives and managers rely on the analyses to run the company.
Many basic analysis programs have a similar structure. In this lesson, we'll take at look at that common pattern.
There's much more to data analysis than this. Building statistical models, writing simulations, real-time analysis… there are whole university degrees in this stuff. The programs we'll write only do the most basic forms of analysis.
h1.
So far, all of the data has been in a worksheet. Here's pseudocode for extracting data from a worksheet into an array:
While there is more data
Get some data
If the data meets some criteria Then
Copy it to an array
EndIf
Loop
In RL, data that comes from other systems, or is downloaded from the Web, might not be in a worksheet. Often it will be in a plain text file. Your program will need to extract data from that.
Here's pseudocode for extracting data from a file into an array:
bc.