To filter the data?

S3
Site user since 29.03.2012
Offline
221
68

If anyone bothered to put the plug-ins have a little problem a little more interesting) is necessary to write a script filtering data

initial data:


[ { 'Id': 0, 'media_category': 'clip'},
{ 'Id': 1, 'media_category': 'promo'},
{ 'Id': 2, 'media_category': 'promo'},
{ 'Id': 3, 'media_category': 'start'},
{ 'Id': 3, 'media_category': 'video'},
{ 'Id': 3, 'media_category': 'anime'},
{ 'Id': 3, 'media_category': 'promo'},
{ 'Id': 4, 'media_category': 'clip'},
{ 'Id': 4, 'meda_category': 'promo'},
{ 'Id': 6, 'media_category': 'xxx'},
]

This is a dictionary, but you can work with it in any format familiar to you - json, etc.

I need to filter the data in such a way that would exclude those rows where the key value 'media_category' == promo or xxx

That is, in the result should be an option


{ 'Id': 0, 'media_category': 'clip'},
{ 'Id': 3, 'media_category': 'start'},
{ 'Id': 3, 'media_category': 'video'},
{ 'Id': 3, 'media_category': 'anime'},
{ 'Id': 4, 'meda_category': 'promo'},
{ 'Id': 4, 'media_category': 'clip'},

Implementation language - your choice. Of course primarily interested in Python, but it will be interesting to compare implementation in php, javascript, c ++, go and other

Thanks in advance and plus in karma to those who will take a constructive part in the topic: beer:

Clarifying questions are welcome!

S
Site user since 30.09.2016
Offline
459
#1

forych cycle?

Отпилю лишнее, прикручу нужное, выправлю кривое. Вытравлю вредителей.
VV
Site user since 19.12.2009
Offline
101
#2

I agree with the foreach on php!

Хостинг https://vk.cc/aAx6uD
SeVlad
Site user since 03.11.2008
Offline
1399
#3
Sly32:
You need to write a script ..Utochnyayuschie questions are welcome!

I do not cope, need help the community? ;)

OK. Excel or normal notebook + 2 mice click / hotkey :)

Делаю хорошие сайты хорошим людям. Предпочтение коммерческим направлениям. Топики помощи с ⓌordPress (https://searchengines.guru/ru/forum/1032910 ) и основы безопасности сайтов ( https://searchengines.guru/ru/forum/774117 ). *** Помощь\консультации в топиках форума - БЕСПЛАТНО. Платные услуги ( https://wp.me/P3YHjQ-3 ) - с бюджетом от 150$ ***
S3
Site user since 29.03.2012
Offline
221
#4
veni_vidi_vivi:
I agree with the foreach on php!

So you write) cycle - the cycle is not the way you want? I am also interested to see the implementation of

SeVlad:
OK. Excel or normal notebook

The data come from the backend to the database and I need to give the front a filtered list of subscriptions it - tell us what side there Excel stick?

Although Python and it allows it

SeVlad:
I do not cope, need help the community?

I'm curious to see different implementations, I can go down the wrong path. even if they get by.

Well, compare the code will be shorter than the language)

SeVlad
Site user since 03.11.2008
Offline
1399
#5
Sly32:
I can go down the wrong path. even if they get by.

Well, you would have shown his version to start with.

S
Site user since 30.09.2016
Offline
459
#6
Sly32:
Well, compare the code will be shorter than the language)

I smell coming srach. For him and instigated this topic. I guessed? Because the code itself is not worth a jigger.

SeVlad
Site user since 03.11.2008
Offline
1399
#7
Sly32:
there is a little problem a little more interesting)

Near here is the task of a more practical . Help the user to send mail with html? Teach him the right methods and tools? 🍿

S3
Site user since 29.03.2012
Offline
221
#8
Sitealert:
I smell coming srach. For him and instigated this topic. I guessed? Because the code itself is not worth a jigger.

Pancake well why just srach? and if constructive discussion? If the code is not worth a damn, it's why I still do not see you from here?

T7
Site user since 19.09.2018
Offline
35
#9

On your favorite Python, something like

 m = [n for n in m if isinstance (n, dict) and n.get ( 'media_category') not in [ 'xxx', 'promo']] 
S3
Site user since 29.03.2012
Offline
221
#10
SeVlad:
Near here is the task of a more practical. Help the user to send mail with html?

Why did you decide so? The response of my tasks will be to use one and a half million subscribers in the month of May) It's time

two - why it my decision? I do not write on php, you know)

three - more banal than to set up sending mail - it is difficult to come up with

Next, I ask on the subject

if there are questions on task - ready explains

To post a new comment, please log in or register