import re


def calculatedNormalisedDataForLines(lines):
    """ Get normalised data for the lines of the file.
    
    This function is intended as an example.
    
    With the help of the function the velocity data of the file are normalized to the absolute value
    of 1 to be able to measure the profile later with a individual current factor.
    
    The parser for the line content is developed as an example for both HUDDSCOL.txt and NYCCCOL.txt.
    The decimal separator is a dot and the column separator is a tab.
    
    The data structure required by the measureProfile() method is returned. The data is structured
    like the following example:
    
    [{"time": 0, "value": 0.1},{"time": 1, "value": 0.4},{"time": 2, "value": 0.3}]
    
    The structure is an array with a dictionary for each step. The dictionary has two keys:
        time: The time point of the value.
        value: The value, what the value is whether voltage, current or other is specified in the
            measureProfile() method.
    
    :param lines: Array with the data lines of the file as string.
    :returns: Explained data structure.
    """
    maxValue = 0
    normalisedData = []
    seperatorRegex = re.compile(r"([0-9,.]+)[\W]+([0-9,.]+)")   
    
    for line in lines:
        linematch = seperatorRegex.match(line)
        if linematch != None:
            data = dict()
            data["time"] = float(linematch.group(1))
            value = float(linematch.group(2))
            if abs(value) > abs(maxValue):
                maxValue = value
            data["value"] = value
            normalisedData.append(data)
    
    for data in normalisedData:
        """
        Normalisation to the biggest Value from -1 to 1.
        """
        data["value"] = data["value"] / abs(maxValue)
    return normalisedData