[Tutor] Menus with dictionaries or lists?
alan.gauld at btinternet.com
Mon Apr 28 22:37:32 CEST 2008
"Norman Khine" <norman at khine.net> wrote
> I have a csv file as follows:
> "us";"United States of America";"Alabama";"Central Alabama"
> "uk";"United Kingdom";"East Anglia";"Cambridgeshire"
> "uk";"United Kingdom";"East Anglia";"Norfolk"
> I am trying to figure out a script on the command line so that you
> get a navigation through which a user can drill down by:
There are XXX records to choose from.
Select a main criteria for filtering list:
Country(C), Region(R), District(D)?
<Display filtered list or a message saying how many selected>
Select a secondary criteria for filtering list:
<Display filtered list or a message saying how many selected if >
Select a District for filtering list:
<List of Unique districts> or <Regex entry field>
Display final list matching criteria.
Provide option for going back a level at each prompt.
> I have some countries for which I don't have data for region or
> county and I would want to exclude this from the list and only
> include the country that has a county.
Not quite sure what you mean, but if you just don't want to display
them thats fairly straightforward to do by testing each record before
> What is the most effective way to do this.
For low data volumes what I've suggested abopve will work with
an in-memory data store - list or dictionary. If volumes are bigger
you may be better buuilding sa SqlLite database and building
up a dynamic SQL query string.
Author of the Learn to Program web site
More information about the Tutor