Convert a CSV file to a PyDbLite base
    src is the file object from which csv values are read
    dest is the name of the PyDbLite base
    If fieldnames is not set, the CSV file *must* have row names 
    in the first line
    fieldtypes is a dictionary mapping field names to a function
    used to convert the string read from the CSV file to the value
    that will be stored in the PyDbLite base. For instance, if the
    field is an integer, the function is the built-in int() function

def csv_to_PyDbLite(src,dest,fieldnames=None,fieldtypes=None,dialect='excel'):
    """Convert a CSV file to a PyDbLite base
    src is the file object from which csv values are read
    dest is the name of the PyDbLite base
    If fieldnames is not set, the CSV file *must* have row names 
    in the first line
    fieldtypes is a dictionary mapping field names to a function
    used to convert the string read from the CSV file to the value
    that will be stored in the PyDbLite base. For instance, if the
    field is an integer, the function is the built-in int() function"""
    import csv
    import PyDbLite
    if not fieldnames:
        _in = csv.DictReader(open(src),fieldnames=fieldnames)
        _in.next()
        fieldnames = _in.fieldnames
    out = PyDbLite.Base(dest)
    kw = {"mode":"override"}
    out.create(*_in.fieldnames,**kw)
    default_fieldtypes = {"__id__":int,"__version__":int}

    if fieldtypes is None:
        fieldtypes = default_fieldtypes
    else:
        fieldtypes.update(default_fieldtypes)
    _in = csv.DictReader(open(src),fieldnames=fieldnames)
    _in.next()
    for row in _in:
        for k in fieldtypes:
            try:
                row[k] = fieldtypes[k](row[k])
            except:
                print k,row[k],fieldtypes[k]
                raise
        out.insert(**row)
    out.commit()