I wrote a Python program that acts on a large input file to create a few million objects representing triangles. The algorithm is:
If you don't care about vertex reuse, you could have two output files--one for vertices and one for triangles. Then append the triangle file to the vertex file when you are done.