6.3. Using Foods Text files

After you have completed your Foods Text file, you can use it just as you would any other Pantry file. Here is an example:

Example 6.2. Using a Foods Text file

$ pantry --print traits-units-blank foods.txt
Milk, reduced fat, fluid, 2% milkfat, with added vitamin A
Group: Cereal and Milk
Date: 2007-06-30 Meal: Breakfast Order: 0006 
1.0 cup (244g)
   quart
   fl oz
   cup

Blueberries, raw
Group: Fruits and Fruit Juices
Order: 0008 
Refuse: 5 percent Stems and green or spoiled berries
5 oz (142g)
   pint as purchased, yields
   cup

Papayas, raw
Group: Fruits and Fruit Juices
Order: 0007 
Refuse: 33 percent Seeds and skin
1 medium (5-1/8" long x 3" dia) (304g)
   small (4-1/2" long x 2-3/4" dia)
   medium (5-1/8" long x 3" dia)
   cup, mashed
   cup, cubes
   large (5-3/4" long x 3-1/4" dia)


The nice thing about Foods Text files is that although you can edit them with your text editor, you can also manipulate them using ordinary Pantry commands. For example:

Example 6.3. Changing a Foods Text file

$ pantry --name "Apples, raw, with skin" --c-date "April \
> 15" --c-qty 1 --c-unit medium --add foods.txt master
$ cat foods.txt
# Sample foods.txt file.
# The first column indicates the source file. It is best to use an absolute pathname
# here.
#source:name:qty:unit:date:meal:group:comment:options
#Options: x=exact match; i=ignore case
/home/massysett/pantry-data/master:Milk, reduced fat, fluid, 2% milkfat, with added vitamin A:1.0:cup:2007-06-30:Breakfast:Cereal and Milk::x
/home/massysett/pantry-data/master:Papayas:1:medium
/home/massysett/pantry-data/master:blueberries, raw:5:oz:::::i
/home/massysett/pantry/sandbox/master:Apples, raw, with skin:1:medium (2-3/4" dia) (approx 3 per lb):April 15::Fruits and Fruit Juices::x

As you can see, when you add foods to a Foods Text file using pantry, appropriate text is added to the end of the file. However, beware that if you change the name of the food using the --c-name option, Pantry will not be able to locate the food in the source file. You can, however, change any of the other traits, although Pantry will override any changes you make to the order trait because the order trait is automatically set to the line number of the food. Thus the --auto-order option has no effect when using Foods Text files.