Skip to content

Instantly share code, notes, and snippets.

@antnieszka
Created September 30, 2016 20:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antnieszka/95cf44027777fe2dcc04398336d75b99 to your computer and use it in GitHub Desktop.
Save antnieszka/95cf44027777fe2dcc04398336d75b99 to your computer and use it in GitHub Desktop.
# TO2 - projekt?
TO2 = False
with open("1-department-list.csv", "r", encoding="utf8") as depart_in:
przedmioty = ()
studenciaki = {}
temp_student = ""
for e in depart_in.readlines():
if e[0] != '\t': # pewno student
temp_student = e.strip().split(";")[0]
studenciaki[temp_student] = {}
else: # raczej przedmiot
grupa_specjalna = False
if TO2:
if e.strip()[0:3] == 'TO2':
grupa_specjalna = True
else:
temp_przedmiot = e.strip().split("-")[0].strip()
else:
temp_przedmiot = e.strip().split("-")[0].strip()
if temp_przedmiot not in przedmioty:
if not grupa_specjalna:
przedmioty = przedmioty + (temp_przedmiot,)
# print("Znaleziono przedmiot: ", temp_przedmiot)
if not grupa_specjalna:
studenciaki.get(temp_student)[temp_przedmiot] = e.strip().split("-")[-1].strip()
else:
studenciaki.get(temp_student)["Technologie obiektowe 2"] = "7" # takie id akurat wolne
print(przedmioty)
print(przedmioty.__len__())
# print(studenciaki)
with open("tabelkowe.csv", "w", encoding="utf8") as out:
wiersz_przedmiotow = ";"
for e in przedmioty:
wiersz_przedmiotow += e
wiersz_przedmiotow += ";"
out.writelines(wiersz_przedmiotow)
out.write("\n")
for student in studenciaki.keys():
out.write(student)
out.write(";")
for przedmiot in przedmioty:
print("sprawdzanie: \"%s\" dla studenta: \"%s\"" % (przedmiot, student))
if studenciaki[student].get(przedmiot) is not None:
out.write(studenciaki[student].get(przedmiot))
out.write(";")
print("\tGrupa studenta: ", studenciaki[student].get(przedmiot))
else:
print("\tStudent nie ma takiego przedmiotu!")
out.write(";")
out.write("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment