Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def suodata_laskut():
- with open("oikeat.csv") as tiedosto:
- if tiedosto.read() == "":
- with open("laskut.csv") as tiedosto:
- vastaus = 0
- for rivi in tiedosto:
- rivi = rivi.replace("\n", "")
- osat = rivi.split(";")
- if "-" in osat[1]:
- vähennys = osat[1].split("-")
- vastaus = int(vähennys[0]) - int(vähennys[1])
- elif "+" in osat[1]:
- summa = osat[1].split("+")
- vastaus = int(summa[0]) + int(summa[1])
- if int(vastaus) == int(osat[2]):
- with open("oikeat.csv", "a") as tiedosto:
- tiedosto.write(rivi+"\n")
- else:
- with open("vaarat.csv", "a") as tiedosto:
- tiedosto.write(rivi+"\n")
- if __name__ == "__main__":
- suodata_laskut()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement