Trying to go thru the contents of a table with the following layout
In this table indexfield and art1 are always filled art2, art3, and art4 can be empty.
In pseudo-code this is what I want to do:

for each art of table where indexfield = x:
   do bladibla
   if last of x:
      do blodiblo

How can I do this in Python ?

Since you title your post with "...csv file", I'll assume you're reading this table one row at a time from a comma delimited file. So, let's say you've opened the file as fid (i.e., fid=open(<file name>)). Then you read through the file, strip off the line feed, split the line on commas and process the resultant list:

for strLine in fid:
    for elem in lstLine[1:]:
       #do your thing
    #do your other thing

How can I fill the value of the indexfield to use for the search ?
Something like:

if lstLine[0]="ab":
for strLine in fid:
    if lstLine[0]=="ab":
       for elem in lstLine[1:]:
          #do your thing
       #do your other thing
    #do something entirely else.

Wow, thank you so much.
Very cool language !

Your code works very well for part 1.
Now I want to take it to the next level.
This is the content of fid:
This is the content of fname:

This is your code for part1:

     for strLine in open(fid):
        if indexfield=="USOR2GB":
           for elem in lstLine[1:]:
              print elem

Instead of print elem I want to use elem as index-field for the fname table
to pick up the price and quantity fields per product. So in the example where
indexfield="USOR2GB" it should fetch USMEG1UD and USHOODBA records from fname (and after testing the qty-columns it should sum pricea of USMEG1UD and USHOODBA, sum priceb of USMEG1UD and USHOODBA etcetera and store list of "summed prices" per indexfield ("USOR2GB" in this example) with indexfield as variable name).
Hopefully it's not getting too confusing.

Thanks pyTony, interesting indeed.
Do you have any experience with multiple csv files where
one is a dictionary with multiple values associated with each key
and these values are used as key in a secondary csv file ?

This is what I figured out so far.
My Python program works, now the challenge is to combine it with Scribus template and generate a pdf.

for strLine in open(arttable):
    paf = pbf = pcf = pdf = pef = pff = pgf = phf = 0
    for elem in lstLine[1:]:
          for item in open(fname):      
            if andexfield == elem:
              pa = lstData[1]
              qa = lstData[2]
              pb = lstData[3]
              qb = lstData[4]
              pc = lstData[5]
              qc = lstData[6]
              pd = lstData[7]
              qd = lstData[8]
              pe = lstData[9]
              qe = lstData[10]
              pf = lstData[11]
              qf = lstData[12]
              pg = lstData[13]
              qg = lstData[14]
              ph = lstData[15]
              qh = lstData[16]
              print andexfield                     
              print pa, pb, pc, pd, pe, pf, pg, ph
              print qa, qb, qc, qd, qe, qf, qg, qh

Assuming you don't need the data after printing it out, I would recommend shortening the code thusly:

            if andexfield == elem:
                print andexfield
                for p in range(1, 17, 2):
                    print p,
                for q in range(2, 17, 2):
                    print q,

The third argument of the range() function is an optional 'step' value, indicating how many values it should increment by each time; for example, range(0, 10, 2) would (in Python 2.x) give a list of [2, 4, 6, 8] as its result (in Python 3.x, range() is a generator; the values returned are the same, but it returns only one value per call, rather than a list).

Thanks, nice programming. Unfortunately I need the data, printing them was just for debugging purposes.

It would still be possible to use the same basic loops to, say, gather the data into a pair of lists. Still, it all depends on just what you need to do with it, I suppose.