I have a SQLFORM to gather some information for processing an excel file.
The form works saving the data to the db no issue.
I would like to be able to send the request.vars to a function to actually
process the contents of the excel using the form data.
The form contains file format(csv,xls,tab,xlsx etc), the tab or sheet in
the workbook, and then the columns for the pertinent data.
Here is what I have so far:
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 for any assistance...
--
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.