Everything after your comment can be deleted. This code is not really necessary. The code before your comment can be simplified to
Generic Load * Inline
Just run this script and look at the data model. Then you will see that the "Generic" prefix has created one field per color. It has also split the table into one table per color.
All the for-loop in the original script does, is to join the three color tables into one single table - which in most cases isn't necessary.