def get_item_count(items, f=None):
    """
    Use this to get a count of items in a collection that doesn't support len(), like a file reader.
    Due to the internal workings of readers, this must be done prior to any reader operations.

    :param items: Object containing the items.
    :param f: File to reset seek index.
    :return: Count of items.
    """
    count = 0
    for _ in items:
        count += 1
    if f:
        try:
            f.seek(0)
        except AttributeError:
            pass
    return count