Hong-Phuc Bui
5 days ago 01eda97ff64ad2570b7105cc5b734f488ce0d47a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
coordinaten = [] #
 
def line_to_coordinate(line:str):
    """
    :param line: string, semi-colon separated
    :return: {"x": ... , "y": ...}
    """
    parts = line.split(";")
    x_str = parts[0].strip()
    x_str = x_str.replace(',', '.')
    x = float(x_str)
 
    y_str = parts[1].strip().replace(',', '.')
    y = float(y_str)
    return {"x": x, "y": y}
 
def is_line_data(line:str) -> bool:
    stripped = line.strip()
    return len(stripped) > 0 and stripped[0] != '#'
 
with open("treibstoff.csv") as f:
    for line in f.readlines():
        if is_line_data(line):
            coordinate = line_to_coordinate(line)
            coordinaten.append(coordinate)
 
print(coordinaten)