Whoops, sent that before completing:

Should have been...

Sorry, the reports module is my own. It is a directory under the modules
directory for that app. this is just my own special code. The important
thing to note is that you have to pass the directory name. The important
part is this:

'%s/%s' % (os.path.join(request.folder,'uploads'), fileName)

where I put the path and fileName together. Now you can reference that file
and do stuff with it. In my reports/brillToDalex method, It looks kinda
like this:

def process(inputFile, userId):
    f = open(inputFile, 'r')
    for line in f.readlines():
        ....



On Thu, Nov 1, 2012 at 9:45 AM, Jim Steil <ato.st...@gmail.com> wrote:

> Sorry, the reports module is my own.  It is a directory under the modules
> directory for that app.  this is just my own special code.  The important
> thing to note is that you have to pass the directory name.  The important
> part is this:
>
> '%s/%s' % (os.path.join(request.folder,'uploads'), fileName)
>
> where I put the path and fileName together.  Now you can reference that
> file and do stuff with it.  In my reports/brillToDalex method, I issue the
> following:
>
> def process(inputFile, userId):
>
> btd.process('%s/%s' % (os.path.join(request.folder,'uploads'), fileName),
> 1)
>
> On Thu, Nov 1, 2012 at 9:11 AM, Paolo Caruccio <paolo.carucci...@gmail.com
> > wrote:
>
>> a simple skeleton code (please check for errors):
>>
>> def page_controller():
>> form = FORM( TABLE (
>>  TR(
>> TD(LABEL('Upload File:')),
>> TD(INPUT(_type='file', name='myfile', id='myfile',
>> requires=IS_NOT_EMPTY()))
>>  ),
>> TR(
>> TD(INPUT(_type='submit',_value='Submit'))
>>  )
>> )
>> )
>>
>> txt_content[]
>>  if form.process().accepted:
>> txt_content = request.vars.myfile.file.readlines()
>> msg = process_file(txt_content)
>>  response.flash = T(msg)
>> elif form.errors:
>> response.flash = T('some errors occurred')
>>  else:
>> pass
>>
>> return dict(form=form)
>>
>> def process_file(txt_content):
>> all_lines = txt_content
>> msg = 'txt not processed'
>> for line in all_lines:
>>  try:
>> ..... your processing code .....
>> msg = 'txt processed succesfully'
>>  except:
>> ..... your processing code .....
>> msg = 'error processing txt'
>>  return msg
>>
>> Il giorno mercoledì 31 ottobre 2012 16:45:19 UTC+1, praveen krishna ha
>> scritto:
>>
>>> Hi,
>>>    For my task I have to upload a text file in form with out zipping it
>>> ,I have prepared the form as:
>>> form = FORM(TABLE(TR(TD('Upload File:', INPUT(_type='file',
>>> name='myfile', id='myfile',
>>> requires=IS_NOT_EMPTY()))),TR(TD(INPUT(_type='submit',_value='Submit')))))
>>>
>>> But I unable to read the file how could it be possible without using
>>> ZipFile.
>>>
>> --
>>
>>
>>
>>
>
>

-- 



Reply via email to