KiCAD - Automating library part creation
The script is already out there, its called KiPart. It does what you need, create spreadsheet with all pins then run csv through the script and your part is generated. 

Here is a nice video tutoiral from the author to follow along https://www.youtube.com/watch?v=hX4l8i4TSWY