Added the code. This was all written in bulk and likely won't see many (or any) edits in the future.
Minor code tweaks and an example CSV file.