I'd like to 'tableize' the source data in a Lua module, and just call something like this, where the function would fetch the data and build an infobox:
...on the page(s) that will require the infobox to have an infobox generated.
This way, when a game update comes by, I could just change the page where the source data and the Pets' module infobox function to update all the places where we have an infobox.
I've read that once we get to the module part, templates have already been expanded, parser functions and extension tags have already been processed, and pre-save transforms (e.g. signature tilde expansion and the pipe trick) have already happened. (Source)
Is it possible? If not, is there an alternative that I could go with to achieve similar results?
I have only tried to make a module (the Hello world), so I'm not a Lua/Module guru yet.
it would be better to just create the module and work with it, than re-asking same question. you will never understand scribunto unless you will try it, not matter of count of questions.
here is example of the module that calls portable infobox template. but you don't need it. just create a module by yourself: it will be much better, than dealing with alien (in all meanings of the word) code.
your module reparses csv for each module call. you can avoid this by converting csv to lua table. although it will not make any visible difference right now, when you have small data string, it will have growing performance impact when your data will grow.
for thousands of entries you most likely will not be able ot use csv at all (lua has memory and time limits).
for big data you woukd like to use mw.loadData. read about this ahead, in order to plan data structure by better way: loaddata will return metatable, so you will need to access to your data via keys in order to not lost performance benefits of the loaddata.