It sounds like you do need the file to persist across multiple requests, so 
the simplest approach might be to create a database table with an upload 
field to store the file. As soon as you're done with the file, then just 
delete the record in the database (the file will be deleted automatically 
as long as you set autodelete=True).

Anthony

On Wednesday, November 19, 2014 12:22:51 AM UTC-5, T.R.Rajkumar wrote:
>
> @Anthony Thanks for your kind reply. I don't need to save the file. That's 
> why w/o db, session becomes handy. I upload the file in master data page 
> having two forms. One form is the SQLFORM.factory for uploading the excel 
> file and the other form is to enter the key parameters. When the second 
> form is submitted this page redirects to another details page where I would 
> like to read the excel file uploaded in the first page and populate the 
> html table in the details page. Yes I would like to discard the excel file 
> upon reading it. Seeking your valuable guidance.
>
> On Tuesday, November 18, 2014 12:06:31 PM UTC+5:30, T.R.Rajkumar wrote:
>>
>> form_upload = SQLFORM.factory(Field('your_excel_file', 'upload',
>> uploadfolder='helloworld/uploads'))
>> if form_upload.process().accepted:
>>         session.your_excel_file = form.vars.your_excel_file
>>
>> def import_from_excel():
>>     workbook = xlrd.open_workbook(session.your_excel_file)
>>
>>
>> When import_from_excel() is called gives rise to the below error.
>> How to access excel file stored in session? 
>>
>> File "F:/trr/web2py/web2py/applications/helloworld/controllers/cms_meas.py" 
>> <http://127.0.0.1:8000/admin/default/edit/helloworld/controllers/cms_meas.py>,
>>  line 255, in import_from_excel
>>     workbook = xlrd.open_workbook(session.your_excel_file)
>>   File "D:\Python\lib\site-packages\xlrd\__init__.py", line 366, in 
>> open_workbook
>>     formatting_info=formatting_info,
>>   File "D:\Python\lib\site-packages\xlrd\__init__.py", line 725, in __init__
>>     f = open(filename, open_mode)
>> TypeError: coercing to Unicode: need string or buffer, NoneType found
>>
>>
>>
>>
>>

-- 
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.

Reply via email to