Category : json

Running this code to normalize json: import pandas as pd import http.client import json import requests # get order book for a specific ticker conn = http.client.HTTPSConnection("api.buyucoin.com") payload = ” headers = { ‘Content-Type’: ‘application/json’ } conn.request("GET", "/ticker/v1.0/liveOrderBook?symbol=USDT-INR", payload, headers) res = conn.getresponse() OrderBook = res.read() print(OrderBook.decode("utf-8")) OrderBook = pd.json_normalize(json.loads(OrderBook),’data’,[‘status’,’sub_status’]) But not getting desired ouptut ..

Read more

I am making a Telegram bot using TeleBot that receives an image through Telegram and creates a link to download the said image. The bot creates a link to the received image in the form of https://api.telegram.org/file/bot{bot_key}/{file_path}, where {bot_key} is the Telegram API key from BotFather and {file_path} represents the Telegram file path of the ..

Read more

i have tried the below code to normalize JSON, but getting error – " AttributeError: ‘int’ object has no attribute ‘values’" Code: import pandas as pd import http.client import json conn = http.client.HTTPSConnection("api.buyucoin.com") payload = ” headers = { ‘Content-Type’: ‘application/json’ } conn.request("GET", "/ticker/v1.0/liveData?symbol=USDT-INR", payload, headers) res = conn.getresponse() data1 = res.read() print(data1.decode("utf-8")) df = ..

Read more

I have some json format php data str: test_str = "a:7:{i:0;a:9:{s:4:"hits";i:15;s:3:"mid";s:32:"d6b82e0be40ee8aeeedbe083051ad72b";s:7:"task_id";i:57117773;s:3:"sad";i:14;s:8:"endpoint";a:2:{s:5:"value";s:25:"ComposerActivity:composer";s:8:"matching";b:1;}s:9:"new_crash";a:2:{s:5:"value";i:-1;s:8:"matching";N;}s:8:"sad_perc";a:2:{s:5:"value";d:0.0027375831052014079;s:8:"matching";b:0;}s:14:"completed_runs";a:2:{s:5:"value";i:7116;s:8:"matching";N;}s:13:"push_blocking";a:2:{s:5:"value";s:11:"In skiplist";s:8:"matching";N;}}i:1;a:9:{s:4:"hits";i:3;s:3:"mid";s:32:"6c6534733fea986c16681382343aec25";s:7:"task_id";i:90749161;s:3:"sad";i:3;s:8:"endpoint";a:2:{s:5:"value";s:25:"ComposerActivity:composer";s:8:"matching";b:1;}s:9:"new_crash";a:2:{s:5:"value";i:-1;s:8:"matching";N;}s:8:"sad_perc";a:2:{s:5:"value";d:0.00058662495111458737;s:8:"matching";b:0;}s:14:"completed_runs";a:2:{s:5:"value";i:7116;s:8:"matching";N;}s:13:"push_blocking";a:2:{s:5:"value";s:7:"Allowed";s:8:"matching";b:0;}}i:2;a:9:{s:4:"hits";i:9;s:3:"mid";s:32:"47a8756bd9d7eff80cbe7830b2a8bad6";s:7:"task_id";i:90587610;s:3:"sad";i:9;s:8:"endpoint";a:2:{s:5:"value";s:45:"InspirationCameraActivity:live_video_composer";s:8:"matching";b:1;}s:9:"new_crash";a:2:{s:5:"value";i:-1;s:8:"matching";N;}s:8:"sad_perc";a:2:{s:5:"value";d:0.0017598748533437622;s:8:"matching";b:0;}s:14:"completed_runs";a:2:{s:5:"value";i:7116;s:8:"matching";N;}s:13:"push_blocking";a:2:{s:5:"value";s:7:"Allowed";s:8:"matching";b:0;}}i:3;a:9:{s:4:"hits";i:71;s:3:"mid";s:32:"1b827259535cf95705c06f74a77658d2";s:7:"task_id";i:80788840;s:3:"sad";i:67;s:8:"endpoint";a:2:{s:5:"value";s:25:"ComposerActivity:composer";s:8:"matching";b:1;}s:9:"new_crash";a:2:{s:5:"value";i:-1;s:8:"matching";N;}s:8:"sad_perc";a:2:{s:5:"value";d:0.013101290574892453;s:8:"matching";b:1;}s:14:"completed_runs";a:2:{s:5:"value";i:7116;s:8:"matching";N;}s:13:"push_blocking";a:2:{s:5:"value";s:7:"Blocked";s:8:"matching";b:1;}}i:4;a:9:{s:4:"hits";i:1;s:3:"mid";s:32:"0943ec4558b6579e2704c7feb089cc60";s:7:"task_id";i:90040539;s:3:"sad";i:1;s:8:"endpoint";a:2:{s:5:"value";s:39:"ProfileFragment:profile_vnext_tab_posts";s:8:"matching";b:1;}s:9:"new_crash";a:2:{s:5:"value";i:-1;s:8:"matching";N;}s:8:"sad_perc";a:2:{s:5:"value";d:0.00019554165037152912;s:8:"matching";b:0;}s:14:"completed_runs";a:2:{s:5:"value";i:7116;s:8:"matching";N;}s:13:"push_blocking";a:2:{s:5:"value";s:7:"Allowed";s:8:"matching";b:0;}}i:5;a:9:{s:4:"hits";i:9;s:3:"mid";s:32:"38c28b4bc2f6e4513b9cb4fa912860ea";s:7:"task_id";N;s:3:"sad";i:9;s:8:"endpoint";a:2:{s:5:"value";s:39:"ProfileFragment:profile_vnext_tab_posts";s:8:"matching";b:1;}s:9:"new_crash";a:2:{s:5:"value";i:-1;s:8:"matching";N;}s:8:"sad_perc";a:2:{s:5:"value";d:0.0017598748533437622;s:8:"matching";b:0;}s:14:"completed_runs";a:2:{s:5:"value";i:7116;s:8:"matching";N;}s:13:"push_blocking";a:2:{s:5:"value";s:7:"Allowed";s:8:"matching";b:0;}}i:6;a:9:{s:4:"hits";i:1;s:3:"mid";s:32:"d71bf31bf1eca1cbaea0e7ee3fee4595";s:7:"task_id";i:90107372;s:3:"sad";i:1;s:8:"endpoint";a:2:{s:5:"value";s:30:"StoryViewerActivity:fb_stories";s:8:"matching";b:1;}s:9:"new_crash";a:2:{s:5:"value";i:-1;s:8:"matching";N;}s:8:"sad_perc";a:2:{s:5:"value";d:0.00019554165037152912;s:8:"matching";b:0;}s:14:"completed_runs";a:2:{s:5:"value";i:7116;s:8:"matching";N;}s:13:"push_blocking";a:2:{s:5:"value";s:7:"Allowed";s:8:"matching";b:0;}}}" I want it to be parsed like below {0: {‘hits’: 15, ‘endpoint’: {‘matching’: True, ‘value’: ‘ComposerActivity:composer’}, ‘task_id’: 57117773, ‘push_blocking’: {‘matching’: None, ‘value’: ‘In skiplist’}, ‘sad_perc’: {‘matching’: False, ‘value’: 0.002737583105201408}, ‘mid’: ‘d6b82e0be40ee8aeeedbe083051ad72b’, ‘sad’: 14, ‘new_crash’: {‘matching’: None, ‘value’: -1}, ‘completed_runs’: {‘matching’: None, ‘value’: 7116}}, ..

Read more