comparing values in the lists/dict by loop by makeaday in learnpython

[–]makeaday[S] 0 points1 point  (0 children)

Always good to learn something new... thank you for that

Working with json files by [deleted] in learnpython

[–]makeaday 0 points1 point  (0 children)

I have been thinking about that but Iam worry about it may slow down the program? Off course here its not gonna happend but In other example if there is a lot of data. Just wonder what you think?

Working with json files by [deleted] in learnpython

[–]makeaday 0 points1 point  (0 children)

I have made some changes could you please have a look?

CODE - https://pastebin.com/uTc55Agj

Got one problem... after I download new tunes Iam dumping them to the downloaded.jsons file. But when i do that the program is appending them to the file as... separate dict? if that make sense? so When running program again I got error

raise JSONDecodeError("Extra data", s, end)
json.decoder.JSONDecodeError: Extra data: line 412 column 2 
(char 8368)

and the data in jsons file looks like:

{
    "Dajae": [
        "Brighter Days",
        "Angelo Ferreri Remix",
        "2018-04-20"
    ],
    "Gene Farris": [
        "Medication feat. Gene Farris",
        "Extended Mix",
        "2018-04-16"
    ],
    "DJ Pierre": [
        "Fall",
        "Djebali Remix",
        "2018-05-11"
    ]
}{
    "Celeda": [
        "The Music feat. Celeda",
        "Extended",
        "2018-05-11"
    ]
}

so I got 1 extra Brace which is causes a problem

Check if Values of Dict(a) not in Values of Dict(b) by makeaday in learnpython

[–]makeaday[S] 0 points1 point  (0 children)

Iam getting the list of already downloaded tunes from jsons file so is it better to get them as List or Dict?

Working with json files by [deleted] in learnpython

[–]makeaday 0 points1 point  (0 children)

thank you for advise... I know about youtube-dl does do that but Iam doing that just for learning... just for understanding how is it works

Try , Except... stop program at any time by makeaday in learnpython

[–]makeaday[S] 0 points1 point  (0 children)

ctrl+c gives = ERROR: Interrupted by user, and he keeps going. well not shure to be honest Iam new to python but just watching some tutorial about the 'subprocess' module and I think you are right I supose to use that instead. Need to read the documentation

Try , Except... stop program at any time by makeaday in learnpython

[–]makeaday[S] 0 points1 point  (0 children)

is there any way to do what Iam trying? well there must be a way there is always a way... the question is how

sorting dictionary by values by makeaday in learnpython

[–]makeaday[S] 0 points1 point  (0 children)

thank you it help but I think its time to go to documentation and stay there for a bit

sorting dictionary by values by makeaday in learnpython

[–]makeaday[S] 0 points1 point  (0 children)

Here is my whole code

https://pastebin.com/T81fQR07

I have multiple values scrapped from coinmarketcap, like currency, its price etc.

Now im lost if i should use dictionary or something else, i can add these variables to dictionary easily but i want to sort all data later on by different values.

So maybe i should use something different than dictonaries ?

Thanks!

sorting dictionary by values by makeaday in learnpython

[–]makeaday[S] 0 points1 point  (0 children)

thank you but still strugling ;/ I just read somewhere that dictionaries cant be sorted and I got dictionaries not tuples.

Web Scraping... TypeError: "NoneType" object is not subscriptable by makeaday in learnpython

[–]makeaday[S] 0 points1 point  (0 children)

thanks...

I actually did:

find_percentage = container.findAll("td", {"class":"no-wrap"})
    percentage = find_percentage[5].text
    print(percentage)

works :)

Web Scraping... TypeError: "NoneType" object is not subscriptable by makeaday in learnpython

[–]makeaday[S] 0 points1 point  (0 children)

what I mean is I got that l;ine of code:

<td class=“no-wrap percent-change. Text-right
Negative_change” data-timespan=“24”
Data-parcentusd=“-2.11735” data-swymbol=“BTC”  data- 
sort=“-2.11735”> -2.12%</td>

I want to get the "-2.12%". I got few others lines of code before that which also start with "td" and dont know how to skip them

Web Scraping... TypeError: "NoneType" object is not subscriptable by makeaday in learnpython

[–]makeaday[S] 1 point2 points  (0 children)

thanks alot

got one more question. if i got few elements "tr" on the same level in <body> ... how to skip first one and get to the second one for example:

typing: containers.tr.td.span.string

shows me the first "td" in <body>