There are several existing scripts that read in 'text files' and parse the 'fields/parts' line-by-line into an array of values [e.g. separated by space/tab/,/;/etc] to use in making geometry of some sort from these as x/y/z/material/layer/etc ...
Find these and see how it's done...