def b2h(num, suffix='B'):
    """Format file sizes as human readable.

    https://stackoverflow.com/a/1094933

    Parameters
    ----------
    num : int
        The number of bytes.
    suffix : str, optional
        (default: 'B')

    Returns
    -------
    str
        The human readable file size string.

    Examples
    --------
    >>> b2h(2048)
    '2.0kB'
    """
    try:
        for unit in ['', 'k', 'M', 'G', 'T', 'P', 'E', 'Z']:
            if abs(num) < 1024.0:
                return '{0:3.1f}{1}{2}'.format(num, unit, suffix)
            num /= 1024.0
        return '{0:.1f}{1}{2}'.format(num, 'Y', suffix)
    except:
        return '-'
