def write_small_or_big_data(data, resource_name, datapackage_dir, max_size=
    10000000.0):
    """Save dataframe as a gzipped CSV if small, HDF if large

    "Large" is determined from the product of the data shape, with a maximum
    of `max_size`.

    Parameters
    ----------
    data : pandas.DataFrame
        The data to save
    resource_name : str
        Name of the data for saving
    datapackage_dir : str
        Absolute path, where to save the data to
    max_size : int or float
        Maximum size of the data to save as a "smaller" CSV format, where
        ncol*nrow < max_size

    Returns
    -------
    info : dict
        Information about the written file, e.g. path, format, compression to
        save with the datapackage
    """
    nrow, ncol = data.shape
    info = {}
    if nrow * ncol < max_size:
        basename = '{}.csv'.format(resource_name)
        data_filename = '{}/{}'.format(datapackage_dir, basename)
        with open(data_filename, 'w') as f:
            data.to_csv(f)
        info['format'] = 'csv'
    else:
        basename = '{}.hdf'.format(resource_name)
        data_filename = '{}/{}'.format(datapackage_dir, basename)
        key = 'data'
        info['format'] = 'hdf'
        info['key'] = key
        data.to_hdf(data_filename, key)
    info['path'] = basename
    return info
