def read_data(path, histories):

    """
    Function that reads the data in a TOPAS simulation scorer output file.
    Assumes the simulation scored a quantity and its standard deviation, meaning
    only two values follow the three coordinates of the scoring voxel.
    Returns the two scored quantities as an arrays of floats along with the header
    lines and coordinates of the scoring voxels. The latter two are used to re-
    constuct the file into the same format using create_new_file().
    """

    with open(path) as file:

        value, std_dev, header, coords = [], [], [], []  # initialize empty arrays

        for line in file:

            if "#" in line:  # only include header lines

                header += [line]

            if not "#" in line:  # only include data lines
                coords += [line.split(",")[:3]]  # save x,y,z coordinates
                values = line.split(",")[3:]  # cut off x,y,z values
                values = [
                    float(value.replace("e", "E").replace("\n", "")) for value in values
                ]  # convert to float
                value += [values[0]]  # unpack value
                std_dev += [values[1]]  # unpack standard deviation

    return value, std_dev, header, coords