Несложная, да. Может относиться к задаче стоило с учетом первой фразы темы:
Sly32: Если кому надоело ставить плагины
danforth: там не редкость те же XML файлы на пару гигов. Или сайтмеп например распарсить у сайта.
Для XML даже для PHP есть средства которые не грузят весь файл в память. Логи - csv построчно легко читаются .
А в целом, да, согласен, что если есть инструменты для потокового чтения JSON это хорошо. "Сомнительная" это я к тому, что я бы в таких JSON файлах данные бы не хранил
Simple, yes. It can relate to the problem of cost, taking into account the first phrase of the theme:
Sly32: If anyone has bothered to put plugins
Danforth: it is not uncommon same XML files for a couple of gigs. Or parse XML sitemap for example at the site.
For XML for PHP even have the funds that do not ship the entire file into memory. Logs - csv row are easy to read.
That if there is to read streaming tools JSON is good as a whole, yes, I agree. "Doubtful," this I mean that I would be in JSON files such data would not be stored
Sly32: истинные питоисты вспомнили бы про фильтры и лямды
Я не истинный 😂 Питон, только по мере надобности. Но, признаю, на питоне, относительно пхп многие вещи делаются гораздо короче, проще и иногда элегантней. Хотя в данной задаче это не очевидно:
По своему все правы в зависимости от того как была понята задача. Можно и на уровне запроса. Если по какой то причине в фильтр запроса (например фуллтекст) не рекомендуется, можно и надстройку написать, где предусмотреть коллбак, который посмотрит в текущем курсоре и не добавит в ответ если что не так:
Sly32: true pitoisty be remembered about filters and lambda
I'm not a true 😂 Python, only when needed. But, I admit, on a python, php regarding many things made much shorter, easier and sometimes more elegant. Although it is not obvious in this problem:
$ A = array_filter ($ a, function ($ v) {return in_array (_arr ($ v, 'media_category'), [ 'promo', 'xxx']);!});
According to its all right, depending on how the task was understood. Possible and at the query level. If for some reason, the query filter (eg fulltekst) is not recommended, you can write and add-on, which provide kollbak, which looks at the current cursor and will not add back if something goes wrong:
It seems to have repeatedly stated that this is a conclusion from the database. Ie ready list of dictionaries in terms of python or an array of arrays / objects in terms of php / js
Danforth: JSON file with your content, for example a file to 10GB
Have the JSON, the idea itself is questionable. If it is a file, then yes, your solution is probably the only thing here is how it will solve the problem.
view sample array sorting with alphanumeric
A huge plus python that has everything for all occasions (pip install natsort)
lambda-выражение для вызова встроенной функции
анонимной
playbacks = filter(lambda _data: _data['media_category'] not in ['promo'], data)
Ну так, в порядке буквоедства
playbacks = filter(lambda _data: _data['media_category'] not in ['promo'], [ {'a':'b'},
{'b':'x'},
{'media_category':'promo'},
])
print(list(playbacks));
Поможет
То, что dict мы абсолютно уверены, т.к. выборка из носкуэл
---------- Добавлено 13.06.2020 в 21:34 ----------
И да, чуть длиннее, но смысл тот же
$a=array_filter($a,function($v){return !in_array(_arr($v,'media_category'),['promo','xxx']);});🍿
lambda-expression is used to invoke functions
anonymous
playbacks = filter (lambda _data: _data [ 'media_category'] not in [ 'promo'], data)
Well, in order pedantry
playbacks = filter (lambda _data: _data [ 'media_category'] not in [ 'promo'], [ { 'A': 'b'},
{ 'B': 'x'},
{ 'Media_category': 'promo'},
])
print (list (playbacks));
Will help
What dict we are absolutely sure, because noskuel of sampling
---------- Posted 13.06.2020 at 21:34 ----------
And yes, a little longer, but the meaning is
$ A = array_filter ($ a, function ($ v) {return in_array (_arr ($ v, 'media_category'), [ 'promo', 'xxx']);!});🍿
А в чем тогда сложность задачи
Несложная, да. Может относиться к задаче стоило с учетом первой фразы темы:
Если кому надоело ставить плагины
там не редкость те же XML файлы на пару гигов. Или сайтмеп например распарсить у сайта.
Для XML даже для PHP есть средства которые не грузят весь файл в память. Логи - csv построчно легко читаются .
А в целом, да, согласен, что если есть инструменты для потокового чтения JSON это хорошо. "Сомнительная" это я к тому, что я бы в таких JSON файлах данные бы не хранил
And what's the complexity of the task
Simple, yes. It can relate to the problem of cost, taking into account the first phrase of the theme:
If anyone has bothered to put plugins
it is not uncommon same XML files for a couple of gigs. Or parse XML sitemap for example at the site.
For XML for PHP even have the funds that do not ship the entire file into memory. Logs - csv row are easy to read.
That if there is to read streaming tools JSON is good as a whole, yes, I agree. "Doubtful," this I mean that I would be in JSON files such data would not be stored
истинные питоисты вспомнили бы про фильтры и лямды
Я не истинный 😂 Питон, только по мере надобности. Но, признаю, на питоне, относительно пхп многие вещи делаются гораздо короче, проще и иногда элегантней. Хотя в данной задаче это не очевидно:
$a = array_filter($a, function($v) { return !in_array( _arr($v, 'media_category'), [ 'promo', 'xxx' ] ); });По своему все правы в зависимости от того как была понята задача. Можно и на уровне запроса. Если по какой то причине в фильтр запроса (например фуллтекст) не рекомендуется, можно и надстройку написать, где предусмотреть коллбак, который посмотрит в текущем курсоре и не добавит в ответ если что не так:
---------- Добавлено 13.06.2020 в 17:37 ----------
разве не текстовая строка Json формата
Вроде неоднократно говорилось, что это вывод из бд. Т.е готовый лист словарей в терминах питона или массив массивов/объектов в терминах php/js
Ну типа
[<class 'dict'>, {'_id': 'eb527ced-03323e0e', 'name': '43253-6010-28(R4)', 'catid': '03323e0e', 'category': 'БОРТОВЫЕ АВТОМОБИЛИ', 'slug': 'kamaz-43253-6010-28-r4', 'fullslug': '/board-truck/kamaz-43253-6010-28-r4', 'hit': 0, 'new': 0, 'novinka': 0, 'akciya': 0, 'cena_po_akcii': 0, 'price': 174121830, 'artikul': 0, 'model': '43253', 'variant': '6010-28(R4)', 'modelid': '43253', 'variantid': '6010-28-r4', 'prm': {'name': '43253-6010-28(R4)', 'kolesnaya_formula': '4х2', 'oshinovka': 2, 'gruzopodemnost_t': 7.82, 'moschnost_ls': 245, 'moschnost_netto_ls': 236, 'kpp': 'ZF6', 'p_o_glavnoj_peredachi': 6.53, 'obem_platformy_m3': 9.3, 'spalnoe_mesto': '─', 'shiny': '10.00R20 11.00R20 11.00R22,5', 'bak_l': 350, 'tsu': '─', 'opisanie': 'МКБ, дв. Сummins 6ISBe4 245, система нейтрализ. ОГ(AdBlue), ТНВД BOSCH, КПП ZF6S1000, рестайлинг', 'vendor': 'KAMAZ'}, 'up': 1591518268.71459, 'upd': 1}]данные в результате
JSON файл с твоим содержимым, допустим файл на 10ГБ
Иметь такой JSON, идея сама по себе сомнительная. Если это файл, то да, ваше решение наверное единственное здесь, которое как то решит задачу.
true pitoisty be remembered about filters and lambda
I'm not a true 😂 Python, only when needed. But, I admit, on a python, php regarding many things made much shorter, easier and sometimes more elegant. Although it is not obvious in this problem:
$ A = array_filter ($ a, function ($ v) {return in_array (_arr ($ v, 'media_category'), [ 'promo', 'xxx']);!});According to its all right, depending on how the task was understood. Possible and at the query level. If for some reason, the query filter (eg fulltekst) is not recommended, you can write and add-on, which provide kollbak, which looks at the current cursor and will not add back if something goes wrong:
---------- Posted 13.06.2020 at 17:37 ----------
It is not a text string Json format
It seems to have repeatedly stated that this is a conclusion from the database. Ie ready list of dictionaries in terms of python or an array of arrays / objects in terms of php / js
What type
[<Class 'dict'>, { '_id': 'eb527ced-03323e0e', 'name': '43253-6010-28 (R4)', 'catid': '03323e0e', 'category': 'AIRBORNE VEHICLES' , 'slug': 'kamaz-43253-6010-28-r4', 'fullslug': '/ board-truck / kamaz-43253-6010-28-r4', 'hit': 0, 'new': 0 'novinka': 0, 'akciya': 0, 'cena_po_akcii': 0, 'price': 174121830, 'artikul': 0, 'model': '43253', 'variant': '6010-28 (R4)' , 'modelid': '43253', 'variantid': '6010-28-r4', 'prm': { 'name': '43253-6010-28 (R4)', 'kolesnaya_formula': '4x2' ' oshinovka ': 2,' gruzopodemnost_t ': 7.82,' moschnost_ls': 245, 'moschnost_netto_ls': 236,' kpp ':' ZF6 ',' p_o_glavnoj_peredachi ': 6.53,' obem_platformy_m3 ': 9.3,' spalnoe_mesto ':' ─ ' , 'shiny': '10 .00R20 11.00R20 11.00R22,5 ',' bak_l ': 350,' tsu ':' ─ ',' opisanie ':' ICD bits. Cummins 6ISBe4 245, a neutralizing system. OG (AdBlue), pump BOSCH, CAT ZF6S1000, restyling ',' vendor ':' KAMAZ '},' up ': 1591518268.71459,' upd ': 1}]data as a result of
JSON file with your content, for example a file to 10GB
Have the JSON, the idea itself is questionable. If it is a file, then yes, your solution is probably the only thing here is how it will solve the problem.
На вашем любимом питоне, как то так
m = [ n for n in m if isinstance(n, dict) and n.get('media_category') not in ['xxx', 'promo'] ]On your favorite Python, something like
сайты про хрюш можно делать только на битриксе => сайты можно делать только на битриксе
А я понял, что битрикс - это кмс для сайтов про хрюш:D 🍿
Снести бы по хорошему этот топик в профильном разделе А лучше в курилку..
Поддерживаю. Тут "мастер", с полной зачисткой, а то что зачистили в курилку в "слав"