Так и запишем -ArbNet, джуновскую задачку решить не смог )) Отмазки не прокатывают. Я думаю тут всем кто решал - есть чем заняться, однако с радостью включились
So we write - ArbNet, dzhunovskuyu task could not solve)) Excuses are not rolled. I think here all who decide - to have something to do, but gladly joined
Мне кажется, у тебя в output останется лишняя запятая в конце
I think, in your output will be an extra comma at the end of
Ты б еще мельче скрин выложил)
You'd even put smaller screen)
ArbNet, Приходи в топик для программистов - порешаем задачки, ждем твое решение)
ArbNet, Come to the topic for programmers - poreshat tasks, waiting for your decision)
Вот полностью рабочий код с посимвольным вычитыванием на Питон
import json import time def truncate_row(data): start = time.time() with open('res-task-1.json', 'w') as res: res.write('[') with open(data) as f: pos = 1 flag = False js = '' while pos: char = f.read(pos) if char == ']': break if char == '{': flag = True if flag: js += char if char == '}': flag = False data = json.loads(js) if data.get('scores') >= 0.7: res.write(json.dumps(data)+',') js = '' size = res.tell() res.truncate(size - 1) with open('res-task-1.json', 'a') as res: res.write(']') print(f'Executing time: {time.time() - start}') truncate_row('task-1.json')
Executing time: 0.2150096893310547
Выходной файл валидный)
Это конечно очень грубо, можно еще оптимизировать
И просьба ко всем - приводить полностью листинг программы, чтобы можно было запустить и почекать время) ---------- Добавлено 15.06.2020 в 10:47 ----------
Это уже будет нарушением условий задачи)
Here is a fully working code character by character subtraction on Python
import json import time def truncate_row (data): start = time.time () with open ( 'res-task-1.json', 'w') as res: res.write ( '[') with open (data) as f: pos = 1 flag = False js = '' while pos: char = f.read (pos) if char == ']': break if char == '{': flag = True if flag: js + = char if char == '}': flag = False data = json.loads (js) if data.get ( 'scores')> = 0.7: res.write (json.dumps (data) + ',') js = '' size = res.tell () res.truncate (size - 1) with open ( 'res-task-1.json', 'a') as res: res.write ( ']') print (f'Executing time: {time.time () - start} ') truncate_row ( 'task-1.json')
The output file is valid)
This course is very tough, can be further optimized
And the request to all - is the full listing of the program to be able to run and pochekat time) ---------- Posted 06.15.2020 at 10:47 ----------
It will be a violation of the conditions of the problem)