table lookup fast, table lookup fast ignore case
This function works very similarly like table lookup top down(), with the only difference that the matching row number in the lookup table
will be memorized. For the next row in the target table, the lookup proccess continues on that memorized row. In there is no match in the
remaining part of the table, then the lookup continues with a 2nd round, namely starting with the 1st row until a matching row has been
identified.
This feature provides signficant performance improvements if your target table and your lookup table are already sorted in alphabetic
order and the input columns in the target table and the search columns in the lookup tables are based on the sorted contents.
Example: You have two large tables sorted alphabetically by town names (roughly 19,000 in the USA). One table contains demographic info, and
the other table contains geological and environmental data. For calculating the ecological footprint per inhabitant, you need to look up the
number of inhabitants for every city. Since both tables are already sorted, the time requierd to look up the entire table is roughly directly
proportional to the length of the target table.
Indirect parameter passing is disabled
6 - 8 (For parameter description and return values: see table lookup() )
table load( lookup, "Examples/Table Lookup Example 1.csv" );
table initialize( target, { Town, Florence, Venice, Florence, Edinburgh, New York, Hamburg, Florence, Munich, New York } );
count[] = table lookup fast ( target, Town, { Food or Beverage, Recommended, Row Number },
lookup, City, { Meal or Drink, Recommendation, '#row' }, true, Counter );
echo("Lookup table after 1st lookup, note the 'Counter' column added:");
table list( lookup );
echo("Note: First lookup for New York is after Edinburgh, so a glass of lager beer is offered instead of a pizza");
echo("Target table after lookup (", count[], " items found):");
table list( target );
Lookup table after 1st lookup, note the 'Counter' column added:
0 : City | Country | Meal or Drink | Recommendation | Rating | Counter
1 : Hamburg | Germany | Meal | Hering | 2 | 1
2 : Hamburg | Germany | Meal | Seafood | 3 |
3 : New York | USA | Meal | Pizza | 5 | 1
4 : New York | USA | Meal | Hamburger | 5 |
5 : Florence | Italy | Drink | Chianti | 4 | 3
6 : Florence | Italy | Meal | Tagliatelli | 5 |
7 : Edinburgh | G. Britain | Drink | Single Malt | 3 | 1
8 : Edinburgh | G. Britain | Meal | Fish & Chips | 3 |
9 : New York | USA | Drink | Lager | 3 | 1
10 : Camarque | France | Meal | Cheese | 3 |
11 : Camarque | France | Spice | Fleur du sel | 4 |
12 : Boston | USA | Meal | Lobster | 4 |
13 : Plzen | Czech Rep. | Drink | Pils | 4 |
14 : Munich | Germany | Meal | Pork | 3 | 1
15 : Munich | Germany | Drink | Weissbier | 5 |
Note: First lookup for New York is after Edinburgh, so a glass of lager beer is offered instead of a pizza
Target table after lookup (8 items found):
0 : Town | Food or Beverage | Recommended | Row Number
1 : Florence | Drink | Chianti | 5
2 : Venice | | |
3 : Florence | Drink | Chianti | 5
4 : Edinburgh | Drink | Single Malt | 7
5 : New York | Drink | Lager | 9
6 : Hamburg | Meal | Hering | 1
7 : Florence | Drink | Chianti | 5
8 : Munich | Meal | Pork | 14
9 : New York | Meal | Pizza | 3