Last active
October 20, 2017 09:04
-
-
Save agp8x/80bdbbe555f84c183d748784a5267021 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
heads = [''] | |
data = [] | |
head_a = False | |
data_a = False | |
new_data = None | |
with open("data.yaml") as src: | |
for line in src: | |
if (not head_a) and (not data_a): | |
if "head" in line: | |
head_a=True | |
if head_a: | |
if "time:" in line: | |
heads.append(line[10:-18]) | |
if "data" in line and not " data" in line: | |
head_a=False | |
data_a=True | |
continue | |
if data_a: | |
if line[-2] == ":": | |
if new_data is not None: | |
data.append(new_data) | |
new_data = [line[2:-1]] | |
else: | |
if not "timestamp" in line: | |
line = line.strip() | |
line = line.replace("c_no___", "-1") | |
line = line.replace("b_maybe", "0") | |
line = line.replace("a_yes__", "1") | |
new_data.append(line.split(":")[-1]) | |
data.append(new_data) | |
print(",".join(heads)) | |
print("\n".join([",".join(entry) for entry in data])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
/var/www/html/cgi-bin/FachschaftsdienstWS1718