https://www.kaggle.com/openfoodfacts/world-food-facts has a retarded sparse matrix structure with the nutrients as columns, lots of columns, like Vitamin B12, Vitaimin C, Zinc, Saturated Fat, etc. This is a sparse matrix because not every product has data for every nutrient...this violates the normalization rules - is actually a spreadsheet, not a database.
I need this normalized properly. The columns should probably be something like ProductID, NutrientID, value, units.
Basically, take the root field values like ID, etc., and put the NutrientID, value, and units next to it, where the value is not null...so a Not Null query for every column.
It would be ideal to have a general purpose scrpt, preferably PHP, but maybe SQL, to do this. If PHP it has to make the database connection, and take the table name, as around 5 configuration variables, along with a way to assign the column names, values, units to database fields in the new table. I can do a lot of this in PHPMyAdmin, I don't need a lot of magic.
In both cases, the column list can pretty easily be gleaned from Information_Schema.
Sample data file is at https://drive.google.com/open?id=1ICCT8IW6KufCo7qvnu8I5ZlcjD6k8396
Copyright © 2019 | Truelancer.com