First, upload fields do not store the full file path, only the filename
itself. The file path is obtained from the Field object, which you are not
persisting in this case because you are using SQLFORM.factory. Also,
uploads with SQLFORM.factory are tricky because the filename includes the
database table name, and with a SQLFORM.factory, the default dummy table
name used is "no_table", which doesn't really exist in the database.
Finally, the "uploadfolder" argument should be a complete filesystem path
(e.g., os.path.join(request.folder, 'uploads')).
Anyway, do you really need to save the file, or could you instead just
directly process the file contents upon upload? If you do need to save the
file, do you also need a way to clean up old files? If you instead need to
permanently save the files, then use SQLFORM with a database table rather
than SQLFORM.factory.
Anthony
On Tuesday, November 18, 2014 1:36:31 AM UTC-5, 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 [email protected].
For more options, visit https://groups.google.com/d/optout.