import re


def initialize_record(fields, shape_record):
    """Initializes a dictionary that stores a shapefile record.

    Args:
        fields: List that stores the shapefile record names

        shape_record: Object that contains a shapefile record
                      and associated shape

    Returns:
        record: Dictionary that stores a shapefile record."""
    record = {}

    for idx in range(0, len(fields)):
        record[fields[idx]] = shape_record.record[idx]

        if isinstance(record[fields[idx]], str):
            record[fields[idx]] =\
                re.sub("\\s+", " ", record[fields[idx]])

    return record