Process uploaded file

85 views
Skip to first unread message

David Jobes

unread,
Jul 10, 2014, 7:56:40 AM7/10/14
to web...@googlegroups.com
I have a db table that holds the files i have uploaded, i need to then be able to process them and add the information into another db table, i have not been able to find anything on it or in any book. suggestions or ideas

Massimo Di Pierro

unread,
Jul 12, 2014, 3:40:10 AM7/12/14
to web...@googlegroups.com
for example, let's say you want to upload text files.

db.define_table('one',Field('filename','upload'),Field('processed','boolean',default=False,writable=False))
db.define_table('two',Field('one','reference one'),Field('results','text'))

def index():
      return dict(form = SQLFORM.grid(db.one))

def process():
      rows = db(db.one.processed=False).select()
      for row in rows:
            (filename, stream) = db.one.filename.retrieve(row.filename) ### magic
            db.two.insert(one = row.id, results = stream.read())
            row.update_record(processed = True)
      return '%s records processed' % len(rows)

David Jobes

unread,
Jul 16, 2014, 9:03:52 AM7/16/14
to web...@googlegroups.com
I will try this, i already have a python script that parsers a file and converts to dsv to then add to db, this is the script i am trying to run, once a upload a file.
Reply all
Reply to author
Forward
0 new messages