Hi again :)
I would like to import a CSV file but set the unique field/column to
*full_name_code* (instead of *uuid*).
So here's what I did:
def import_csv():
form = SQLFORM.factory(
Field('csv_file','upload',uploadfield=False)
)
if form.process().accepted:
ff = request.vars.csv_file.file
db.table.import_from_csv_file(ff, unique='full_name_code')
response.flash = 'Import Successful!'
return locals()
But…. it just adds records and I end up with duplicate full_name_codes in
the database.
And this happens even though I have set:
db.define_table('table',
Field('full_name_code', 'string',unique=True),
...
)
May I know how I can import CSV using a unique field that I specify?
Thank you!
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.