Hi folks, How to read an uploaded file object line by line? This seemingly easy task stumps me. Now I am totally lost. :-/
def restore(): form = SQLFORM.factory(Field ('backup','upload',requires=IS_UPLOAD_FILENAME())) if form.accepts(request.vars,keepvalues=True,session=None): # response.flash = type(form.vars.backup.file) # It says it is an instance (of what?) # response.flash = type(form.vars.backup.file.file) # It says it is a file object. Good, but "file.file" is wired enough. # response.flash = form.vars.backup.file.read() # response.flash = form.vars.backup.file.file.read() # The above two lines all return an empty string, ALWAYS. response.flash = [l for l in form.vars.backup.file.file] # And the above line does not read any data either. # Please help. # Actually I gonna use import_from_csv_file() for a restore. # But now the import_from_csv_file() can not detect any data. return form # Thanks in advance! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---