Nutrient Calculator

 by msuzuki777
cheeseburger.jpg
Nutritional calculator: If you enter in what you ate during a day, it will calculate how many calories, carbohydrates, fiber, fats and cholesterol you ate. This could be useful for any type of diet.

WARNING: This Instructable comes with no guarantees. There are too many factors that are not under my control. It is also not endorsing any specific diet.

This LAZY OLD GEEK went to his MD. She basically said I was pre-diabetic and sent me to a nutritionist. My nutritionist said I should watch my carbohydrates. (She said a lot of other things but I’m OLD so focused on carbs). I should limit myself to 180 grams of carbs per day. Being a GEEK, I decided to write my own nutritional logger.

The USDA has a great nutritional database with lots of information on nutrition:
http://fnic.nal.usda.gov/nal_display/index.php?info_center=4&tax_level=1
http://www.ars.usda.gov/Services/docs.htm?docid=8964

And they have a nice little program so that you can look up most anything you want and get the nutritional information on it.
http://www.nal.usda.gov/fnic/foodcomp/search/

This may have all of the information you may need. My problem is that I wanted to know all of the nutrient information for a day. The USDA databases come in different types (and versions). Since I planned to write my program in Visual Basic Express (see GPS for Lazy Old Geeks for more information on VB Express), I chose to use the Microsoft Access version. Now, don’t panic, you shouldn’t need MS Access or know how to use it to use my program.
 
 
Remove these adsRemove these ads by Signing Up

Step 1: Designing program

Boring.jpg
Unless you’re interested in writing your own program or are a glutton for details(punishment), skip this step. It is rather boring.

PROBLEM: The original database is 107mBytes and hard to work with.
SOLUTION: For anybody familiar with relational databases, you probably know they’re very complex with relationship diagrams and rules and restrictions for entering and modifying data. Well, this SR23.mdb nutritional database is one of them. For my purposes, I removed all of the relationships and tables except for the main one called ABBREV. This is the one included in this Instructable.

In relational database terminology a record is all of the information for an item. In this case a record will be a description of the item and all of the nutrients associated with that item.
For those of you who have access to MS Access, there are over 7000 records in this table. For my use, I went in and removed 1000s of these records for foods that I would probably never eat, like Alcoholic Beverages and Baby Food. I also removed several categories for vitamins and such that I don’t care about. Since everyone's tastes and eating habits are different, I left all the records in the attached database.

The core of the program is just accepting the nutrients for the selected food item, placing them in the four meal categories, then summing them up for a total. 

PROBLEM: I decided to export my daily report in CSV format, comma separated values. This makes it easier to be read into MS Excel or OpenOffice or GoogleDocs. Unfortunately, the Short Description field in the database allows commas. This would make the information unusable when read into Excel.
“CHEESE,COTTAGE,NONFAT,UNCRMD,DRY,LRG OR SML CURD”
SOLUTION: There are alternatives to comma separated like semi-colon, but I chose to replace the commas in the description field with colons.
“CHEESE:COTTAGE:NONFAT:UNCRMD:DRY:LRG OR SML CURD”
 
Lulu_Flores says: May 3, 2011. 7:40 PM
Hi, your instructable its really cool, I'm a nutritionist and my husband it's a software developer, a few days ago he made me a little program like yours, its so funny to find something like this made by the pacient itself. Here in mexico we use a system wich is very useful that involves portions and types of food and the nutritionist its who make the calculation about the specific nutrients and gives the patient a lot of sugesstions about how many portions of every type of food he/she can eat and with these options he/she can choose or cook his own dishes every day.

Good luck with your carbs!!
msuzuki777 (author) in reply to Lulu_FloresMay 3, 2011. 9:22 PM
Thanks.
Actually, I have a nutritionist who works with my MD. She was the one that suggested I lower my carbs to about 180 grams a day. This was because my A1C(blood sugar) was a little high. She also uses portion control. After two months following her suggestions, I actually lost 19 pounds, mostly belly fat, even though I wasn't trying to lose weight. But the important thing is that I feel a lot better, have more energy and can exercise more. She also said it would help my high blood pressure and it did.
So I have gained a lot of respect for nutritionists such as yourself. My nutritionist made a major difference in my overall health.
As to writing this program, well, I was a hardware/software developer before I retired and like to stay involved. I also wrote an Instructable on a pedometer I built to monitor my daily walks. Exercise was also brought up by my nutritionist.

In this case, I would say my nutritionist was more helpful than my MD. But on the other hand, my MD was the one who referred me to a nutritionist.
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!