Microsoft Excel .xls format (as well as the others) saves its files
out in custom binary formats. It is very difficult to import them
unless you have a way of decoding the binary format.
Using csv, you can easily set up auto-importers (as long as the csv
data-structure is fairly static).

This is a bit hacky, but you should be able to get the idea...
########### CSV Example
def importer():
    my_inserts=[]
    form=SQLFORM.factory(
        Field('csv_file', 'upload' ,
uploadfolder=os.path.join(request.folder,'static/temp'))
    )
    if form.accepts(request.vars, session):
        my_file=open(os.path.join(request.folder, 'static/temp',
'form.vars.csv_file), 'r')
        line=my_file.readline()
        while line !="":
            # Be careful how you delimit / split your vars!
            my_vars=line.split(",")  # or whatever
            try:
                my_inserts.append(
                    db.my_table.insert(
                        field_one=my_vars[0]
                    )
                )
            except:
                # Error handling...
                pass
        my_file.close()
        ## Delete the file...
        os.unlink(os.path.join(request.folder, 'static/temp',
form.vars.csv_file))
    return dict(form=form, inserts=my_inserts)
###############################################################

Obviously it would be beneficial to do some validation etc. before
hand. There's almost definitely some decent python-based csv-parsing
module out there (and a better way to accomplish this task), but with
the way that the csv files (which I'm importing) are generated, I have
to manually parse them due to poor csv-exporting facilities in the
responsible apps.

Martin

On Feb 2, 6:27 pm, mart <msenecal...@gmail.com> wrote:
> sticking purely to text, is there a difference between an excel file
> and csv? if formatted properly, it should be the same thing. Extension
> names are only incidental, if web2py has the extension hard coded in
> its look up, then you should be able to simply rename the file...
>
> On Feb 2, 9:58 am, Bruno Rocha <rochacbr...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Take a look at this pack:http://www.python-excel.org/
>
> > Bruno Rochahttp://about.me/rochacbruno/bio

Reply via email to