cricketbird
Registered User.
- Local time
- Today, 15:14
- Joined
- Jun 17, 2013
- Messages
- 118
I have a database containing nutrient information for a variety of foods. We regularly get nutrient reports from various analytical laboratories. The reports are in excel, and they name both the foods and nutrients with a variety of non-standardized names. The data tends to come to us in wide/crosstab format, but my database tables are structured in long/normalized format.
My current process for importing these data is:
This process is tedious and prone to error (mine). I feel I would be better off developing a form that would allow me to match the lab sample names with our food names, the lab nutrient names with our nutrients, and import everything automatically. I just can't figure out how to start. Is Access even the best tool for this?
The various structures are below. Any suggestions on an approach would be greatly appreciated.
CB
Example Lab 1 Report:
Food Protein Fat Calcium
Apples 5 5 2
Bananas 4 9 3
Example Lab 2 Report:
Food Protein(g) Fat(g) Calcium(mg/kg)
Apple 6 6 3
Banana 5 10 5
Flattened/Normalized File from R combining both labs:
Food Nutrient Value Lab_ID Date
Apple Protein_g 5 1 12/1/2016
Apple Fat_g 5 1 12/1/2016
Apple Calcium_mg 2 1 12/1/2016
Banana Protein_g 4 1 12/1/2016
Banana Fat_g 9 1 12/1/2016
Banana Calcium_mg 3 1 12/1/2016
Apple Protein_g 6 2 12/1/2016
Apple Fat_g 6 2 12/1/2016
Apple Calcium_mg 3 2 12/1/2016
Banana Protein_g 5 2 12/1/2016
Banana Fat_g 10 2 12/1/2016
Banana Calcium_mg 5 2 12/1/2016
My database:
FOOD_TABLE
Food_ID
Food_Name
etc.
NUTRIENT_TABLE
Nutrient_ID
Nutrient_Name
NUTRIENT_DATA
Data_ID
Data_Date
Lab_ID
Food_ID
Nutrient_ID
Nutrient_Value
My current process for importing these data is:
- Manually rename each food to match our food names
- Manually rename each nutrient to match our nutrient names
- Use R (statistics software) to "flatten" the data (see below)
- Import flattened spreadsheet into Access
- Run an append query
This process is tedious and prone to error (mine). I feel I would be better off developing a form that would allow me to match the lab sample names with our food names, the lab nutrient names with our nutrients, and import everything automatically. I just can't figure out how to start. Is Access even the best tool for this?
The various structures are below. Any suggestions on an approach would be greatly appreciated.
CB
Example Lab 1 Report:
Food Protein Fat Calcium
Apples 5 5 2
Bananas 4 9 3
Example Lab 2 Report:
Food Protein(g) Fat(g) Calcium(mg/kg)
Apple 6 6 3
Banana 5 10 5
Flattened/Normalized File from R combining both labs:
Food Nutrient Value Lab_ID Date
Apple Protein_g 5 1 12/1/2016
Apple Fat_g 5 1 12/1/2016
Apple Calcium_mg 2 1 12/1/2016
Banana Protein_g 4 1 12/1/2016
Banana Fat_g 9 1 12/1/2016
Banana Calcium_mg 3 1 12/1/2016
Apple Protein_g 6 2 12/1/2016
Apple Fat_g 6 2 12/1/2016
Apple Calcium_mg 3 2 12/1/2016
Banana Protein_g 5 2 12/1/2016
Banana Fat_g 10 2 12/1/2016
Banana Calcium_mg 5 2 12/1/2016
My database:
FOOD_TABLE
Food_ID
Food_Name
etc.
NUTRIENT_TABLE
Nutrient_ID
Nutrient_Name
NUTRIENT_DATA
Data_ID
Data_Date
Lab_ID
Food_ID
Nutrient_ID
Nutrient_Value