This i'm sure is very simple, but i can't find the right words to explain what i mean to Google, so my searches have come up empty.
I have a variable that i'm printing to the console. All good.
I'd like to filter/select the variable output, so i can reference it in a new variable. I just don't know the right syntax for the command.
This is the variable:
all_orderbooks = client.get_orderbook_ticker()
print(all_orderbooks)
This then outputs a huge amount of data, a snippet is here:
[{'symbol': 'ETHBTC', 'bidPrice': '0.02475200', 'bidQty': '0.00800000', 'askPrice': '0.02475700', 'askQty': '112.26500000'}, {'symbol': 'LTCBTC', 'bidPrice': '0.00469900', 'bidQty': '0.05000000', 'askPrice': '0.00470100', 'askQty': '70.00000000'}, {'symbol': 'BNBBTC', 'bidPrice': '0.00177020', 'bidQty': '73.94000000', 'askPrice': '0.00177060', 'askQty': '10.34000000'}, {'symbol': 'NEOBTC', 'bidPrice': '0.00112600', 'bidQty': '8.71000000', 'askPrice': '0.00112700', 'askQty': '981.97000000'}, {'symbol': 'QTUMETH', 'bidPrice': '0.00734200', 'bidQty': '296.42000000', 'askPrice': '0.00736400', 'askQty': '296.33000000'}, {'symbol': 'EOSETH', 'bidPrice': '0.01107500', 'bidQty': '300.00000000', 'askPrice': '0.01108900', 'askQty': '300.00000000'}, {'symbol': 'SNTETH', 'bidPrice': '0.00010647', 'bidQty': '10188.00000000', 'askPrice': '0.00010703', 'askQty': '1917.00000000'}, {'symbol': 'BNTETH', 'bidPrice': '0.00345900', 'bidQty': '0.82000000', 'askPrice': '0.00346000', 'askQty': '535.00000000'}, {'symbol': 'BCCBTC', 'bidPrice': '0.00000000', 'bidQty': '0.00000000', 'askPrice': '0.00000000', 'askQty': '0.00000000'}, {'symbol': 'GASBTC', 'bidPrice': '0.00017920', 'bidQty': '11.55000000', 'askPrice': '0.00017980', 'askQty': '115.18000000'}, {'symbol': 'BNBETH', 'bidPrice': '0.07145400', 'bidQty': '23.87000000', 'askPrice': '0.07154800', 'askQty': '93.35000000'}, {'symbol': 'BTCUSDT', 'bidPrice': '9280.37000000', 'bidQty': '0.02339500', 'askPrice': '9280.38000000', 'askQty': '0.49950000'}, {'symbol': 'ETHUSDT', 'bidPrice': '229.74000000', 'bidQty': '1.76697000', 'askPrice': '229.75000000', 'askQty': '144.09608000'}, {'symbol': 'HSRBTC', 'bidPrice': '0.00000000', 'bidQty': '0.00000000', 'askPrice': '0.00000000', 'askQty': '0.00000000'}, {'symbol': 'OAXETH', 'bidPrice': '0.00000000', 'bidQty': '0.00000000', 'askPrice': '0.00000000', 'askQty': '0.00000000'}, {'symbol': 'DNTETH', 'bidPrice': '0.00000000', 'bidQty': '0.00000000', 'askPrice': '0.00000000', 'askQty': '0.00000000'}, {'symbol': 'MCOETH', 'bidPrice': '0.02187700', 'bidQty': '44.94000000', 'askPrice': '0.02205000', 'askQty': '0.48000000'}, {'symbol': 'ICNETH', 'bidPrice': '0.00000000', 'bidQty': '0.00000000', 'askPrice': '0.00000000', 'askQty': '0.00000000'}, {'symbol': 'MCOBTC', 'bidPrice': '0.00054290', 'bidQty': '7.00000000', 'askPrice': '0.00054390', 'askQty': '0.30000000'}, {'symbol': 'WTCBTC', 'bidPrice': '0.00003810', 'bidQty': '922.47000000', 'askPrice': '0.00003830', 'askQty': '8641.66000000'}, {'symbol': 'WTCETH', 'bidPrice': '0.00153900', 'bidQty': '3.35000000', 'askPrice': '0.00154800', 'askQty': '43.06000000'}, {'symbol': 'LRCBTC', 'bidPrice': '0.00000992', 'bidQty': '785.00000000', 'askPrice': '0.00000997', 'askQty': '25373.00000000'}, {'symbol': 'LRCETH', 'bidPrice': '0.00040116', 'bidQty': '98.00000000', 'askPrice': '0.00040320', 'askQty': '67.00000000'}, {'symbol': 'QTUMBTC', 'bidPrice': '0.00018200', 'bidQty': '1.23000000', 'askPrice': '0.00018220', 'askQty': '915.96000000'}, {'symbol': 'YOYOBTC', 'bidPrice': '0.00000110', 'bidQty': '82154.00000000', 'askPrice': '0.00000111', 'askQty': '365041.00000000'}, {'symbol': 'OMGBTC', 'bidPrice': '0.00016630', 'bidQty': '938.17000000', 'askPrice': '0.00016670', 'askQty': '900.83000000'}, {'symbol': 'OMGETH', 'bidPrice': '0.00671100', 'bidQty': '330.64000000', 'askPrice': '0.00673800', 'askQty':
I'd like to be able to filter/select specific subjects within the text, i.e "symbol:" and then just the symbols would be displayed.
I think i have to create a new variable and specify the target i'd like i.e print(all_orderbooks.symbol) or print(all_orderbooks)_symbol, but efforts so far have been fruitless.
any help would be greatly appreciated.
This was my resolution
all_orderbooks = client.get_orderbook_ticker()
for order in all_orderbooks:
ordersymbol = (order['symbol'])
print(ordersymbol)
Many Thanks
ok I figured it out, it works, but if there's a better way then i'm definitely happy to learn :)
all_orderbooks = client.get_orderbook_ticker() for order in all_orderbooks: ordersymbol = (order['symbol']) print(ordersymbol)
Thanks all!