Create a :class:`SQLarray` from *filename*.

    Uses the filename suffix to detect the contents:
      rst, txt
          restructure text (see :mod:`recsql.rest_table`
      csv
          comma-separated (see :mod:`recsql.csv_table`)

    :Arguments:
      *filename*
          name of the file that contains the data with the appropriate
          file extension
      *kwargs*
          - additional arguments for :class:`SQLarray`
          - additional arguments :class:`recsql.csv_table.Table2array` or
            :class:`recsql.rest_table.Table2array` such as *mode* or
            *autoncovert*.

def SQLarray_fromfile(filename, **kwargs):
    """Create a :class:`SQLarray` from *filename*.

    Uses the filename suffix to detect the contents:
      rst, txt
          restructure text (see :mod:`recsql.rest_table`
      csv
          comma-separated (see :mod:`recsql.csv_table`)

    :Arguments:
      *filename*
          name of the file that contains the data with the appropriate
          file extension
      *kwargs*
          - additional arguments for :class:`SQLarray`
          - additional arguments :class:`recsql.csv_table.Table2array` or
            :class:`recsql.rest_table.Table2array` such as *mode* or
            *autoncovert*.
    """

    Table2array = {'rst': rest_table.Table2array,
                   'txt': rest_table.Table2array,
                   'csv': csv_table.Table2array,
                   }
    # see convert.Autoconverter for the kwargs; *active*/*autoconvert*
    # is for the Table2array class
    _kwnames = ('active', 'autoconvert', 'mode', 'mapping', 'sep')
    kwargsT2a = dict((k,kwargs.pop(k))  for k in _kwnames if k in kwargs)
    kwargsT2a.setdefault('mode', 'singlet')
    # Note: sep=False is the only sane choice because we cannot deal  yet
    #       with numpy list structures for import into the db
    kwargsT2a['sep'] = False

    root, ext = os.path.splitext(filename)
    if ext.startswith('.'):
        ext = ext[1:]
    ext = ext.lower()
    kwargsT2a['filename'] = filename
    t = Table2array[ext](**kwargsT2a)
    kwargs.setdefault('name', t.tablename)
    kwargs['columns'] = t.names
    kwargs['records'] = t.records    # use records to have sqlite do type conversion
    return SQLarray(**kwargs)