table digest, table digest ignore case
These functions work very similarly like table integrate(). Instead of stopping at the first match in the lookup table, this function family looks up all entries in the lookup table and includes these rows looked up in the data integration proedure. The search procedure through the lookup table will always be top-down. If only one match has been identified, then the behavior is the same as in table integrate(). In case 2 or more matching enties are found in the lookup table, then the following happens:
Additional features:
Indirect parameter passing is disabled
6 - 9 (For parameter description and return values: see table integrate() )
table initialize( nute facts, // Nutritional facts, source: ndb.nal.usda.gov
{ { Food, Ingredient, Portion },
{ potato chips, fat, 0.34 },
{ potato chips, carbohydrates, 0.50 },
{ potato chips, sodium, 0.08 },
{ potato chips, proteins, 0.07 },
{ potato chips, others, '' }, // Remaining weight subtracted from above (--> operation identifer 'mul')
{ broccoli, water, 0.88 },
{ broccoli, proteins, 0.03 },
{ broccoli, carbohydrates, 0.06 },
{ broccoli, others, '' }, // Remaining weight subtracted from above (--> operation identifer 'mul')
{ spring water, water, 1.00 } } );
table initialize( target, { { Name, Favorite Food },
{ Rafael, Broccoli }, { Steve, Parmesan cheese }, { Stephanie, Parmesan cheese },
{ Jane, Potato chips }, { Nick, Potato chips }, { Fred, Spring water } } );
echo("Target table before looking up with expanding contents:");
table list ( target );
count[] = table digest ignore case( target, Favorite Food, { Ingredient, Portion }, nute facts, Food,
{ Ingredient, Portion }, { overwrite, add}, true, Counter );
echo("Lookup table:");
table list ( nute facts );
// Note that food portions are multiplied with the weight of the food.
echo("After expanding (listing ingredients and calculating their weights):");
echo("The portions are added up and yield resuts of 1 or less.");
echo("Note: Nothing found for parmesan cheese.");
echo("Target table after lookup (", count[], " items found):");
table list ( target );
Target table before looking up with expanding contents:
0 : Name | Favorite Food
1 : Rafael | Broccoli
2 : Steve | Parmesan cheese
3 : Stephanie | Parmesan cheese
4 : Jane | Potato chips
5 : Nick | Potato chips
6 : Fred | Spring water
Lookup table:
0 : Food | Ingredient | Portion | Counter
1 : potato chips | fat | 0.34 | 2
2 : potato chips | carbohydrates | 0.50 | 2
3 : potato chips | sodium | 0.08 | 2
4 : potato chips | proteins | 0.07 | 2
5 : potato chips | others | | 2
6 : broccoli | water | 0.88 | 1
7 : broccoli | proteins | 0.03 | 1
8 : broccoli | carbohydrates | 0.06 | 1
9 : broccoli | others | | 1
10 : spring water | water | 1.00 | 1
After expanding (listing ingredients and calculating their weights):
The portions are added up and yield resuts of 1 or less.
Note: Nothing found for parmesan cheese.
Target table after lookup (15 items found):
0 : Name | Favorite Food | Ingredient | Portion
1 : Rafael | Broccoli | others | 0.97
2 : Steve | Parmesan cheese | |
3 : Stephanie | Parmesan cheese | |
4 : Jane | Potato chips | others | 0.99
5 : Nick | Potato chips | others | 0.99
6 : Fred | Spring water | water | 1
table digest smart
table digest with rules
table digest with rules once
table lookup
table integrate
table expand