I am writing my first python program(at least in a really long time). Its purpose is to take csv or pipe delimited files and convert them to html pages. Was going to be excel but its just not worth the headache. Everyone viewing the reports is doing just that viewing simple tables.

I need to scan through a list that contains headers to my table.
If one of the elements is a tuple and one of the elements of the tuple is "s" set self.sort to the index of the tuple in the header list and then replace the element in header with a two field tuple containing everything that was not 's'.

header = ['my first column',('my second num column','s','r'),(' my third num column','r') ]

I pass header to a function actually a method but lets pretend its just a plain old function. Be careful reading the below code may cause random strokes. I have woken up twice laying on the floor disoriented.... :)

Actual code in my working example used to call function ...

report.set_header( ['','Ext','Name','',('Calls',
'r','s'),('Ring','r'),('Talk','r'),('Wait','r'),('Max Talk','r') ] )

    def set_header(self,header):
        list = []
        for cindex in range(len(header)):
            if type(()) == type(header[cindex]):
                for index in range(len(header[cindex]) ):
                    if header[cindex][index] == 's':
                        self.sort = cindex
                        for tindex in range(len(header[cindex])):
                            if tindex != index: list.append(header[cindex][tindex])
                        header[cindex] = tuple(list)
        self.header = header

TIA,
Paul
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to