Sites like https://www.fuzzwork.co.uk/blueprint/ and http://games.chruker.dk/eve_online/market.php?group_id=2 have already invented that wheel. A lot easier than creating your own (unless you consider that part of the fun).
Also bear in mind that several factors including blueprint material efficiency (ME), facility bonuses and number of runs can change the material requirement.
Accurate costing will require you to maintain a moving average for materials you have in inventory which is OK if you’re running a business but Eve is a game. I use Fuzzworks to set a floor price for the stuff I build and update it once a month. As long as I don’t chase the market below that price I know I’m profitable.