Hi,
you are not telling us about columns. Are you trying to check if all collumns in the row are identical with some other row in the table? If yes, I would try to sort columns in the select. Than something like this can work (untested):

counter=0
lastRow=""
for actualRow in merge_table.select(orderBy = merge_table.q.firstColumn,orderBy = merge_table.q.secondColumn):
    if actualRow is lastRow:
        counter+=1
    else:
        if counter:
            write actual columns + counter+"D" to the file
            counter = 0
    lastRow=actualRow

HTH

Petr JakeŇ°

On Mon, Jan 5, 2009 at 11:23 PM, C Vora <to.chetanvora@gmail.com> wrote:
Hi

I'm somewhat new to Python and SQLObject (but have worked with ORM Wrappers before with Java). I have inherited a project which uses the above extensively. I have a somewhat novice question but couldn't find obvious answers so am posting here.

So the code I have basically does a .select() on a merge table and creates an output file (Comma separated say) with columns I'm interested in . I want to now additionally mark in this file -

a. duplicates that occur in succession only
b. objects that have certain values for a column

So for eg, if row X and row Y are duplicates, I want to have in the file a single row with the letter D at the end to mark Duplicate.

Whats the best way of doing this?

I thought of this pseudo-code:

for x in merge_table.select()
    retrieve next row y    ->> (how??)
    if x==y       //duplicate
       add x to file & mark appropriately in file
    else
       add x and y to file
       reposition cursor correctly to next unread row (if needed, how?)

I was trying to find  a way to do this with SQLObject but couldn't easily figure out. I would like to avoid complicated cursor logic if I can help it.

Any pointers would be appreciated.

TIA,
CV
------------------------------------------------------------------------------

_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss