Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import os
- def get_file(filename):
- file = open(filename)
- #print(file.readline())
- dic = {}
- d1 = ""
- lista = []
- for line in file:
- columns = line.split()
- if columns[1] == '30':
- print(columns[2])
- d = columns[2]
- U = columns[3]
- if d1 == "":
- d1 = d
- lista.append(U)
- elif d1 == d:
- lista.append(U)
- else:
- dic[d1] = lista
- del lista[:]
- d1 = d
- lista.append(U)
- return(dic)
- #filename = 'input.txt'
- filename = r'E:/Obliczeniowa_bio_kom/zad3/input.txt'
- slownik = get_file(filename)
- file2 = open('wynik.txt', 'w')
- for key in slownik:
- for el in slownik[key]:
- file2.write(key + ";" + el + '\n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement