diff --git a/3.py b/3.py index f6541a6..726d000 100644 --- a/3.py +++ b/3.py @@ -95,5 +95,15 @@ if brackets is not None: result = result[:len(result) - 2] + '\n' result += '}' with open('output.json', 'w', encoding='UTF-8') as output: - output.write(result) -print(result) + result = result.replace('\n', '') + r = '' + data = False + for key, i in enumerate(result): + if i != ' ' and not data: + r += i + if data: + r += i + if i == '"' and result[key - 1:key+1] != r'\"': + data = not data + output.write(r) + print(r) diff --git a/5.py b/5.py index 7e15487..d2c13a0 100644 --- a/5.py +++ b/5.py @@ -5,7 +5,7 @@ row = {} columns = ['subject', 'weekday', 'time', 'group', 'audience', 'teacher', 'type', 'format'] header = 'Предмет,День недели,Время,Группа,Аудитория,Учитель,Тип урока,Формат урока' -with open('input.yaml', encoding='UTF-8') as f: +with open('input-csv.yaml', encoding='UTF-8') as f: for i in f.readlines()[1:]: if i.strip()[0] == '-': if row: diff --git a/input-csv.yaml b/input-csv.yaml new file mode 100644 index 0000000..ab68b03 --- /dev/null +++ b/input-csv.yaml @@ -0,0 +1,17 @@ +lessons: + - subject: История России и мира в ХХ веке + weekday: Четверг + time: 10:00-11:30 + group: ИРИ 2.2 + audience: Ауд. 1410, Кронверкский пр., д.49, лит.А + teacher: Айба Тамара Гурамовна + type: Практ\nика + format: Очно + - subject: История России и мира в ХХ веке + weekday: Четверг + time: 15:20-16:50 + group: ИРИ 2 + audience: Ауд. Lemon Classroom (1419), Кронверкский пр., д.49, лит.А + teacher: Пригодич Никита Дмитриевич + type: Лекция + format: Очно - дистанционный "], \ No newline at end of file diff --git a/input.yaml b/input.yaml index 838c002..7b68a81 100644 --- a/input.yaml +++ b/input.yaml @@ -1,5 +1,5 @@ lessons: - - subject: История России и мира в ХХ веке + - subject: Ист"ория России и мира в ХХ веке hella: 7,3 chto: - a @@ -14,12 +14,15 @@ lessons: type: Практика format: Очно - subject: История России и мира в ХХ веке - weekday: Четверг + weekday: Четверг # world + # Hello time: 15:20-16:50 audience: Ауд. Lemon Classroom (1419), Кронверкский пр., д.49, лит.А teacher: Пригодич Никита Дмитриевич type: Лекция format: Очно - дистанционный, + chot: yes + nea: 33.6 wawa: - mama: mia ech: toumio diff --git a/output.json b/output.json index d391678..7da6abb 100644 --- a/output.json +++ b/output.json @@ -1,44 +1 @@ -{ - "lessons": [ - { - "subject": "История России и мира в ХХ веке", - "hella": "7,3", - "chto": [ - "a", - "b", - "c", - "d" - ], - "Hello": true, - "weekday": "Четверг", - "time": "10:00-11:30", - "audience": "Ауд. 1410, Кронверкский пр., д.49, лит.А", - "teacher": "Айба Тамара Гурамовна", - "type": "Практика", - "format": "Очно" - }, - { - "subject": "История России и мира в ХХ веке", - "weekday": "Четверг", - "time": "15:20-16:50", - "audience": "Ауд. Lemon Classroom (1419), Кронверкский пр., д.49, лит.А", - "teacher": "Пригодич Никита Дмитриевич", - "type": "Лекция", - "format": "Очно - дистанционный,", - "wawa": [ - { - "mama": "mia", - "ech": "toumio" - }, - { - "mama": "mia", - "ech": "toumio" - }, - { - "mama": "mia", - "ech": "toumio" - } - ] - } - ] -} \ No newline at end of file +{"lessons":[{"subject":"Ист\"ория России и мира в ХХ веке","hella":"7,3","chto":["a","b","c","d"],"Hello":true,"weekday":"Четверг","time":"10:00-11:30","audience":"Ауд. 1410, Кронверкский пр., д.49, лит.А","teacher":"Айба Тамара Гурамовна","type":"Практика","format":"Очно"},{"subject":"История России и мира в ХХ веке","weekday":"Четверг","time":"15:20-16:50","audience":"Ауд. Lemon Classroom (1419), Кронверкский пр., д.49, лит.А","teacher":"Пригодич Никита Дмитриевич","type":"Лекция","format":"Очно - дистанционный,","chot":true,"nea":33.6,"wawa":[{"mama":"mia","ech":"toumio"},{"mama":"mia","ech":"toumio"},{"mama":"mia","ech":"toumio"}]}]} \ No newline at end of file