if your CSV has col names that match a table field names (as defined in web2py's db.define_table) you simply do
db.define_table('workers',Field('w_organisation'),...., migrate=False) db.workers.import_from_csv_file(open('filename.csv')) migrate=False because I assume the table already exists in database, set to to True if the table is to be created. On Tuesday, 21 July 2015 02:07:34 UTC-5, Yebach wrote: > > Hello > > I would like to import csv file into a database table - user imports > > how do you recommend to do it. I guess telling users to set the column > names matching the headers in CSV but how do i match them after for import. > I also have to add two fields with user id and another one that is based > on user id to be inserted > > > My table is > > CREATE TABLE workers > ( > id serial NOT NULL, > w_organisation integer, > w_user integer, > w_status integer, > w_first_name character varying(32), > w_last_name character varying(32), > w_nick_name character varying(32), > w_email character varying(64), > w_note text, > CONSTRAINT workers_pkey PRIMARY KEY (id) > > ) > > > I am strugling with import function > > Please help i need this fast > > 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.