Solutions above was with stream_get_line, a pack of characters to the separator + preg_match. one character reading makes it easier to solve the problem.
Especially if slightly complicate the task. The json
Sitealert: Он утверждает, что это очень важная задача
Да ладно, шутит наверное.
Sitealert: Да нет же. Он получает данные из базы данных
Вообще не суть откуда. Рекурсия, это к тому что могло бы быть и так в задаче:
{
'id': 0,
'media_category': 'clip',
'child' : {
'id': 22,
'media_category': 'clip',
'child' : {
'id': 27,
'media_category': 'clip',
'child' : {
'id': 77,
'media_category': 'xxx',
}
}
}
}
Sitealert: He argues that this is a very important task
Come on, probably joking.
Sitealert: No. It receives data from the database
It never is coming from. Recursion, is to ensure that it could have been so in the problem: { 'Id': 0 'Media_category': 'clip', 'Child': { 'Id': 22, 'Media_category': 'clip', 'Child': { 'Id': 27, 'Media_category': 'clip', 'Child': { 'Id': 77, 'media_category': 'xxx', } } } }
Gerga: Лучше как можно раньше отсечь ненужные данные...
Sly32 задал абстрактный вопрос - задачу для первоклассника. Не суть как эта задача появляется. Это может быть рекурсивно. Ну вот, например, на таком объекте:
Gerga: Better as soon as possible to cut off the unnecessary data ...
Sly32 asked the abstract question - challenge for a first grader. Not the essence of this task is displayed. This can be recursive. Well, for example, at such a facility:
IMHO, only brute force characters will
Solutions above was with stream_get_line, a pack of characters to the separator + preg_match. one character reading makes it easier to solve the problem.
Especially if slightly complicate the task. The json
[ {And we must find scores.max, for example more than 500, and the object format is flexible"Id": 2234,
"Scores": {
"Max": 267,
"Min": 17
}
}
{
"Id": 2235
"Name": "OOOYO",
"Price": 200319.12,
"Scores": {
"Max": 408,
"Min": 78
}
}
Slightly changing the code
problem is easily solved
------------
or you can drive and zadalbyvat core siskolami reading 1 byte.
Yes, constructive comments, but 20 minutes working hard to jot down. To me at least. :(
content = data.read()
В задаче запрещено грузить весь файл
Загружать весь файл полностью и распаковывать в массив нельзя.
content = data.read ()
The problem is forbidden to ship the entire file
Download the entire file completely and unpack the array can not.
Про запись в результата файл сразу не заметил.
Но там несложно, если пустой просто пишем "[{json_encode найденного}]"
дальше идем в конец, находим позицию "]" и с этой позиции дописываем ",{json_encode найденного}]"
Pro record in the results file is not immediately noticed.
But there is easy, if a blank simply write "[{json_encode found}]"
then go to the end, we find the position of the "]" and from that position we finish ", {json_encode found}]"
Он утверждает, что это очень важная задача
Да ладно, шутит наверное.
Да нет же. Он получает данные из базы данных
He argues that this is a very important task
Come on, probably joking.
No. It receives data from the database
Лучше как можно раньше отсечь ненужные данные...
Sly32 задал абстрактный вопрос - задачу для первоклассника. Не суть как эта задача появляется. Это может быть рекурсивно. Ну вот, например, на таком объекте:
db.runCommand({'collStats':'ttu'})
{
"ns" : "teсh.ttu",
"size" : 843057200,
"count" : 3367400,
"avgObjSize" : 250,
"storageSize" : 90828800,
"capped" : false,
"wiredTiger" : {
"metadata" : {
"formatVersion" : 1
}
.................
"totalIndexSize" : 641056768,
"indexSizes" : {
"_id_" : 355459072,
"name_text_text_text" : 285597696
},
"scaleFactor" : 1,
"ok" : 1
Например не удалять, а оставить "bytes currently in the cache" > xxxx
Оно там есть где то в .......... удаленном
----------
Вы ввели слишком длинный текст (37822 символов). Пожалуйста, сократите его до 12000 символов.
Сократил как мог
Better as soon as possible to cut off the unnecessary data ...
Sly32 asked the abstract question - challenge for a first grader. Not the essence of this task is displayed. This can be recursive. Well, for example, at such a facility:
db.runCommand ({ 'collStats': 'ttu'})
{
"Ns": "tesh.ttu"
"Size": 843057200,
"Count": 3367400,
"AvgObjSize": 250,
"StorageSize": 90828800,
"Capped": false,
"WiredTiger": {
"Metadata": {
"FormatVersion": 1
}
.................
"TotalIndexSize": 641056768,
"IndexSizes": {
"_Id_": 355459072,
"Name_text_text_text": 285597696
}
"ScaleFactor": 1,
"Ok": 1
For example do not remove and leave "bytes currently in the cache"> xxxx
It is there somewhere in the remote ..........
----------
You entered too much text (37822 characters). Please reduce it to 12,000 characters.
He reduced as he could
посмотреть пример сортировки массива с алфавитно-цифровыми
Огромный плюс питона, что есть все на все случаи жизни (pip install natsort)