Skip to content

Instantly share code, notes, and snippets.

@agp8x
Last active October 20, 2017 09:04
Show Gist options
  • Save agp8x/80bdbbe555f84c183d748784a5267021 to your computer and use it in GitHub Desktop.
Save agp8x/80bdbbe555f84c183d748784a5267021 to your computer and use it in GitHub Desktop.
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]))
@agp8x
Copy link
Author

agp8x commented Oct 20, 2017

/var/www/html/cgi-bin/FachschaftsdienstWS1718

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment