I think
db[form.vars.table].import_from_csv_file(request.vars.csvfile)
should be
db[form.vars.table].import_from_csv_file(request.vars.csvfile.file)
On Wednesday, 30 January 2013 14:29:08 UTC-6, Jack wrote:
>
> Hi all,
>
> I've recently started playing around with web2py and i have encountered a
> problem with the csv importing function.
> I have a table defined called 'production' and i have already implemetned
> a smartgrid that will allow me to view,edit each row in the table.
> However, I want to implement a function for the users much like the one in
> appadmin where I can upload a csv file and have its data appended to the
> existing table. If someone can tell me how to do it or show me a direction
> as to where to start it'd be much appreciated.
>
> EDIT:
> I found a block of code while browsing the forums:
>
> def import_table():
> form = SQLFORM.factory(Field('table',requires=IS_IN_SET(db.tables)),
>
> Field('csvfile','upload',uploadfield=False))
> form.process()
> if form.accepted:
> try:
>
> db[form.vars.table].import_from_csv_file(request.vars.csvfile)
> except: form.errors.csvfile = 'invalid file'
> return dict(form=form)
>
> but I get an error saying invalid file when I try to upload.
>
>
--
---
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.