I am trying to loop a data load into a qvd level; however having problems...

The data comes from .html files titles 2001.html to 2265.html but some are missing so all in all 187 HTML files. One is GDP, other one Population and so on...

I am trying to loop over "@[number]" tables where each @ is a new country (therefore F1 is "Country" field@) and F2 is a measure with data (say GDP). The number of tables @1, @2.... can go up to hundreds and I don't know at any point how many tables there are (as per pic below). @4 gives headings: Country, [names measure] (I am not interested in @1 to @3 but that's a detail).

Q1: how to do the loop so each country is loaded with all measures (from all files) and data for that measure.

Q2: data for the measure sometimes contains multiple figures for different years (see picture). Subfield () would be the obvious first thing to do here, but if you have any other/ better ideas, I am listening