For the record, To import preserving ids, import_from_csv_file() needs as parameters: (given a csv with `id` column and not using another unique column (ex. `uuid`))
*id_offset = {} id_map = None* If the table is not empty, it's needed to tuncate() before importing, or use parameter restore=True for the function to do the truncate() db.table.import_from_csv_file(ofile, id_offset={}, id_map=None) The bits inside the function import_from_csv_file in dal.py are: if not (id_map or cid is None or id_offset is None or unique_idx): csv_id = long(line[cid]) curr_id = self.insert(**dict(items)) if first: first = False # First curr_id is bigger than csv_id, # then we are not restoring but # extending db table with csv db table id_offset[self._tablename] = (curr_id-csv_id) \ if curr_id > csv_id else 0 # create new id until we get the same as old_id+offset while curr_id < csv_id+id_offset[self._tablename]: self._db(self._db[self][colnames[cid]] == curr_id).delete() curr_id = self.insert(**dict(items)) On Tuesday, August 21, 2012 at 3:35:56 AM UTC+2, Alan Etkin wrote: > > > Here's a part of the function import_from_csv_file in trunk dal.py. > Judging > > by its description it appears to provide the ability to preserve the > ids. > > Yes I saw it too, but I cannot find within the code where the original > ids are used. I added an extra id_preserve argument and modified the > method to do insert or update without id mapping, but I could not test > it so far. Besides, as you already mentioned, the non-trunk version > does not support preserving ids and setting id_map parameter doesn't > either. > > Regards > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.