Part of the project involves importing some data from text files into a database. I have a property list that contains, for each different file type, the expected fields that should be in the "header" (first line) of the file. So I have a function that looks like this:
get_header(Type) ->
Headers = [
{cpu_usage, ["host", "user_pct", "system_pct", "iowait_pct", "idle_pct", "timestamp"]},
{smb_users, ["host", "num_connections", "timestamp"]},
{tot_bytes, ["host", "num_kbytes", "timestamp"]},
{tot_files, ["host", "num_files", "timestamp"]},
... etc ...
],
proplists:get_value(Type, Headers).
To handle new formats, I pretty much just need to add the expected fields to this list. What's a good way to do that so that the program does not need to be recompiled? I was thinking of using an ets table that I load either in program initialization or lazy-style on the first call to the function. Is this the right approach?
Thanks,
Allan