You could use a add-on like this

It's originally used for pasting codes and scripts, but you can use it for pasting txt as well.
I used it a couple of times, and seems to work fine.
Just an idea, to keep it simple. Scripting all of it from the ground sounds like to much work to me.

Good luck in any case.