I am trying to create a form to import and process an excel file passing in
the attributes of the file like file format(csv,tab,xls,xlsx), the tab or
sheet and the location of the columns containing the needed data.
On submit I would like to pass the request.vars to a function to actually
process the data. However I have been unsuccessful in getting the
request.vars passed to the function.
Any help welcomed.
def form1():
record = db.table1(request.args(0))
url = URL('download')
form = SQLFORM(db.table1, record, fields=['f1', 'f2', 'f3', 'f4', 'f5',
'f6', 'f7', 'f8', 'f9', 'f10', 'f11', 'f12', 'f13'], deletable=True,
showid=True,upload=url, formstyle='table3cols')
if request.vars.f2 != None:
form.vars.f1 = request.vars.f2.filename
if form.accepts(request.vars, session):
oncreate_event (processdata(request.vars))
response.flash = 'The form has been successfully submitted.'
elif form.errors:
response.flash = 'Please correct the error(s).'
return dict(form=form)
def processdata():
vars=request.vars
folder = "C:\\web2py\\application\\app\\working\\"
directory = os.path.join(folder, vars.f3)
if not os.path.exists(directory):
os.makedirs(directory)
filepath = os.path.join(folder, vars.f3, vars.f2)
process excel file....
Thanks in advance.
--
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.