[[+content_image]]
M
M
Master Ruby2021-11-09 21:14:38
Python
Master Ruby, 2021-11-09 21:14:38

How to get the desired value from the string?

I don’t know how to get only the name of the bet and the coefficient from the line

["pinnacle","update_markets","PINTN97C6CD59FD7","9122741,0",[["TOTALS__OVER(22.5)",0,"1.806","","{\"key\":\"s;0;ou;22.5\",\"market_name\":\"totals\",\"dest\":\"over\",\"matchup_id\":1436579810,\"league_id\":6869,\"parent_id\":1435648317,\"participant_id\":null,\"is_special\":false}"],["TOTALS__UNDER(22.5)",0,"2.02","","{\"key\":\"s;0;ou;22.5\",\"market_name\":\"totals\",\"dest\":\"under\",\"matchup_id\":1436579810,\"league_id\":6869,\"parent_id\":1435648317,\"participant_id\":null,\"is_special\":false}"]

I need to get only the name of the bet (example. TOTALS__OVER(22.5) ) and the keff itself. ( 1.806 ).
Is it possible to do this without using regular expressions. I thought about converting to JSON format.
I repeat, at the output we get class string, don't let them confuse you with [].

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
S
Sergey Karbivnichy, 2021-11-09
@Dunaevlad

import json

s = r'["pinnacle","update_markets","PINTN97C6CD59FD7","9122741,0",[["TOTALS__OVER(22.5)",0,"1.806","","{\"key\":\"s;0;ou;22.5\",\"market_name\":\"totals\",\"dest\":\"over\",\"matchup_id\":1436579810,\"league_id\":6869,\"parent_id\":1435648317,\"participant_id\":null,\"is_special\":false}"],["TOTALS__UNDER(22.5)",0,"2.02","","{\"key\":\"s;0;ou;22.5\",\"market_name\":\"totals\",\"dest\":\"under\",\"matchup_id\":1436579810,\"league_id\":6869,\"parent_id\":1435648317,\"participant_id\":null,\"is_special\":false}"]'

data = json.loads(s+']]')

print(data[4][0][0])
print(data[4][0][2])

TOTALS__OVER(22.5)
1.806

Or like this:
import json

s = r'["pinnacle","update_markets","PINTN97C6CD59FD7","9122741,0",[["TOTALS__OVER(22.5)",0,"1.806","","{\"key\":\"s;0;ou;22.5\",\"market_name\":\"totals\",\"dest\":\"over\",\"matchup_id\":1436579810,\"league_id\":6869,\"parent_id\":1435648317,\"participant_id\":null,\"is_special\":false}"],["TOTALS__UNDER(22.5)",0,"2.02","","{\"key\":\"s;0;ou;22.5\",\"market_name\":\"totals\",\"dest\":\"under\",\"matchup_id\":1436579810,\"league_id\":6869,\"parent_id\":1435648317,\"participant_id\":null,\"is_special\":false}"]'

data = json.loads(s+']]')

# print(data[4][0][0])
# print(data[4][0][2])


for x in data[4]:
  print(x[0] +' - '+ x[2])

TOTALS__OVER(22.5) - 1.806
TOTALS__UNDER(22.5) - 2.02

K
kaktak255, 2021-11-09
@kaktak255

If the amount of data does not change, then count the quotes and start from them.
It turns out that the name of the bet will be between 9-10 quotes, and the coefficient between 11-12

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question