To filter the data?

danforth
Site user since 18.12.2015
Offline
153
#31

Sly32, re-read it, I wrote above, you did not JSON. As in the original problem, and in the example of what should happen.

Junior Web Developer
Sly32
Site user since 29.03.2012
Offline
252
#32
Sitealert:
This line, I immediately will form the desired list. And you will not need any grimaces and jumps.

There is a condition of the problem, there is the original data - your answer is never fit them. I do not see the code that can run and see how it fulfills

---------- Posted 13.06.2020 at 15:24 ----------

Danforth:
Sly32, re-read it, I wrote above, you did not JSON

Yes, not the JSON, it IterableObject, tried universally simplified. The original data can be viewed as a list of json-s, to simplify and resolve on this basis, that would not be tied to the concepts of Python

S
Site user since 30.09.2016
Offline
469
#33
Sly32:
There is a condition of the problem, there is the original data - your answer is never fit them.

And I showed you how to get the correct data, based on your statements

Sly32:
The data come from the backend to the database
I won your Olympics, let my prize.
Отпилю лишнее, прикручу нужное, выправлю кривое. Вытравлю вредителей.
Sly32
Site user since 29.03.2012
Offline
252
#34
Sitealert:
And I showed you how to get the correct data, based on your statements

If I could filter at the base - I would have done, I have been working with the findings and do not run in each time base. I did not specify that the data stored in DynamoDB - noSQL basis of your request, and generally does not help. There are different options and conditions - for the problem to be treated is one of them.

If you do not have enough knowledge - do not climb and with unclear answers.

Gerga
Site user since 02.08.2015
Offline
94
#35

Sly32, as a variant without php foreach:


$ ExcludeCategories = 'promo | xxx';

$ Data = preg_replace (
"/{(.*?)'Media_category ':' ({$ excludeCategories}) '}, / (*.?)",
''
$ data
);
Sly32
Site user since 29.03.2012
Offline
252
#36

Gerga, Thanks for the reply. In this embodiment, the source data, you will first need to convert to a string, and then later on it to do a search and replace, right?

Gerga
Site user since 02.08.2015
Offline
94
#37

Sly32, these data are:


[ { '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'},
]

Is not a text string Json format?

S
Site user since 30.09.2016
Offline
469
#38
Sly32:
If you do not have enough knowledge - do not climb and with unclear answers.

It you do not have enough knowledge to formulate the problem clearly.

Did you get it is not clear what data is not clear what kind of environment it is not clear by what means, and you want them to treat it is not clear what language.

danforth
Site user since 18.12.2015
Offline
153
#39

Sly32, and you decide how, his same task? Here you have the JSON file with your content, for example a file to 10GB, and there a couple of tens of millions of lines:


[ {
"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"
}
]

Conditions are the same, show me how you open the file and line otfiltruesh

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

 $ Ooo = Core :: dbmo () 
-> resultCallback (
function ($ doc, $ filter = null) {
if (in_array (_arr ($ doc, 'media_category'), [ 'bad1', 'bad2'])) return null;
# ......
return $ doc;
}
) -> find ( 'zap',
[ '$ Text' => [ '$ search' => 'to filter the data']
]
[ 'Limit' => 1000
'Projection' => [ 'Score' => [ '$ meta' => 'textScore'],
# ........
]
'Sort' => [ 'Score' => [ '$ meta' => 'textScore']
]
]
) -> rows ();


---------- Posted 13.06.2020 at 17:37 ----------

Gerga:
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

 async def do_sly32 (): 
document = await db.xlsitems.find_one ({ '_ id': 'eb527ced-03323e0e'})
print ([type (document), document])
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.

To post a new comment, please log in or register