To filter the data?

Gerga
Site user since 02.08.2015
Offline
94
#51
timo-71:
It seems to have repeatedly stated that this is a conclusion from the database. Ie final sheet dictionaries in terms of the python, or an array of arrays / objects in terms php / jsNu type

Yeah, of course. Those. It will first be made to work for a collection, which is not a desired object, and then you want to delete these items? Better as soon as possible to cut off the unnecessary data ...

T7
Site user since 19.09.2018
Online
46
#52
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:

 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 ..........


"WiredTiger": {
"Cache": {
"Bytes currently in the cache": 108254,

----------


You entered too much text (37822 characters). Please reduce it to 12,000 characters.

He reduced as he could

S
Site user since 30.09.2016
Offline
469
#53
timo-71:
Sly32 asked the abstract question - challenge for a first grader.

He argues that this is a very important task. 😎

Sly32:
The response of my tasks will be to use one and a half million subscribers

timo-71:
Not the essence of this task is displayed. This can be recursive.

No. It receives data from the database.

Sly32:
The data come from the backend to the database
Отпилю лишнее, прикручу нужное, выправлю кривое. Вытравлю вредителей.
T7
Site user since 19.09.2018
Online
46
#54
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',
}
}
}
}
tommy-gung
Site user since 22.11.2006
Offline
271
#55
Sly32:
to cope with at least etoyPoka from phpeshnikov no solutions ...

Are you serious or what?

https://www.google.com/search?client=firefox-bd&q=php+%D1%84%D0%B8%D0%BB%D1%8C%D1%82%D1%80%D0%B0%D1% 86% D0% B8% D1% 8F + json +% D0% B4% D0% B0% D0% BD% D0% BD% D1% 8B% D1% 85

here is the solution of the non-programmers))

Well, Chet doubt that this database is no built-in way to filter data

Здесь не могла быть ваша реклама
S3
Site user since 29.03.2012
Offline
239
#56
Gerga:
Better as soon as possible to cut off the unnecessary data ...

Undoubtedly, the better. But there is business logic, and within it is not always possible

Well, that's an example of an example in this case, I will try to explain why it is not profitable to do at the database level. Request to postgress done 1 time, then the data stored in the radishes and various case studies I need to get different totals. The task - only one of them. I do not need every time to knock in the database, I am working with the already received collection.

Therefore it is necessary to solve by means of language and not talk - how else to do it.

tommy-gung:
here is the solution of the non-programmers))

I'm not interested in what is in Google - it was interesting to offer people to play with something more than customize plugins. Anyone who knows how to think - was involved and suggested solutions, babblers began to reason ...

at the end - the code in Python - the shortest and most readable)

Those who replied in essence - thanks for an interesting discussion)

---------- Posted 14.06.2020 at 13:24 ----------

timo-71:
Come on, probably joking.

Important, but I did not say that the complex or for seniors - so fun. I like to have spent more time writing tests than on the task itself)

tommy-gung
Site user since 22.11.2006
Offline
271
#57
Sly32:
at the end - the code in Python - the shortest and most readable)

but also short! = is the fastest?

Well and readability is probably a subjective concept in the present case

S3
Site user since 29.03.2012
Offline
239
#58
tommy-gung:
but also short! = is the fastest?

Check, if in doubt)

D
Site user since 18.12.2015
Offline
147
#59
Sly32:
at the end - the code in Python - the shortest and most readable)

Whiling away - yes, and readable - definitely not.

Sly32:
Check, if in doubt)

And the slowest.

Well, again, you're not thrown off all the code file.

Разработка и поддержка высоконагруженных проектов.
S3
Site user since 29.03.2012
Offline
239
#60
Danforth:
Well, again, you're not thrown off the whole code file


data = [ { 'Id': 0, 'media_category': 'clip'},
{ 'Id': 1, 'media_category': 'promo'},
{ 'Id': 2, 'media_category': 'promo'},
{ 'Id': 3, 'meda_category': 'promo'},
{ 'Id': 4, 'media_category': 'clip'}]


def filter_data (data):
return filter (lambda _data: _data.get ( 'media_category') not in [ 'promo'], data)


result = filter_data (data)
for item in result:
print (item)

in fact, the code itself - lines 9-10, the rest - to check any pitonovskoj console. As part of the task, I need to insert 2 lines to the existing code - a key check, you need to filter and filtering itself.

About speed - it is clear that the first will be faster, but it is compiled into spython in reality, there has not much important.

Dve and principle, I have nothing against the code on php, this is not a topic for sracha)

Thank you all for your participation, we will have in Minsk - happy Crossing for a beer. I think the topic is exhausted

To post a new comment, please log in or register