given that you wrote your own parser, why are you having problems with updates ? just pass only the columns you need to update to the update_or_insert statement....
On Monday, May 20, 2013 5:41:11 PM UTC+2, David S wrote: > > I've got some csv files which need to be imported to a table. However the > import_from_csv_file function doesn't seem to work because the files can > (and almost always do) contain errors and to the best of my knowledge that > function cannot fix errors on the fly. Anyway, I decided to write my own > csv reading function which puts each line into a list and then uses > update_or_insert to get each line into the db. > > The problem I'm having is there are two csv files for each entry in the > table (think product_inspection_1.csv and product_inspection_2.csv, matched > by serial #), and when using update_or_insert the inspection 2 results can > overwrite the inspection 1 results and vice versa. > > Is there a way using update_or_insert to conditionally update a column in > a row? Something like: > > if col_1: > only update col_2 > if col_2: > only update col_1 > > I've been able to get something working by using an insert, catching an > exception when the serial #s conflict, and then selectively updating the > columns which need updating. But it's kind of like a moped: it gets the job > done but you wouldn't your friends to see you using it. > > Does update_or_insert have this capability? Is there another function > which might do this in a more concise manner? > > David > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

