Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import csv
- #data = []
- #with open('pytania.txt', newline='') as inputfile:
- # for row in csv.reader(inputfile):
- # if row.find('\question'):
- # data.append(row)
- pytania = []
- tempPyt = []
- odpowiedzi = []
- tempOdp = []
- que = False
- nr = 0
- with open('pytania.txt') as inputfile:
- for line in inputfile:
- if line.find('\question')!=-1:
- tempPyt.append(line.strip().split(','))
- if line.find('\Eanswer')!=-1:
- que = False
- odpowiedzi.append(tempOdp)
- tempOdp = []
- if que:
- if line.find('\ca')!=-1:
- tempPyt.append(nr)
- tempOdp.append(line.strip('\ca').split(','))
- else:
- tempOdp.append(line.strip('\ica').split(','))
- nr=nr+1
- if line.find('\Banswer')!=-1:
- que = True
- nr = 0
- #print(pytania)
- print(odpowiedzi)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement