将JSON解析为Google Spreadsheet Python

时间:2017-08-02 23:10:35

标签: python json google-apps-script google-sheets

我正在尝试将ShapeShift API中的Pairs Info调用到Google SpreadSheet。

我致电:https://shapeshift.io/marketinfo/

应该返回类似于此的JSON:

[
{
    "rate": "787.32227488",
    "limit": 0.74761076,
    "pair": "BTC_ICN",
    "maxLimit": 0.93451345,
    "min": 0.0004924,
    "minerFee": 0.2
},
{
    "rate": "0.00122699",
    "limit": 607.31986909,
    "pair": "ICN_BTC",
    "maxLimit": 759.14983636,
    "min": 3.15955766,
    "minerFee": 0.002
},
{
    "rate": "57.83625391",
    "limit": 0.74761076,
    "pair": "BTC_MLN",
    "maxLimit": 0.93451345,
    "min": 0.000102,
    "minerFee": 0.003
}

我希望数据以这种方式填充我的电子表格:

速率限制对maxLimit min minerFee ...... ...... ...... ......

这是我到目前为止所做的:

类数据(ShapeShiftAPI):     def init (自我):

    ShapeShiftAPI.__init__(self)

    scope = ['https://spreadsheets.google.com/feeds']
    credentials = ServiceAccountCredentials.from_json_keyfile_name('config.json', scope)
    gc = gspread.authorize(credentials)

    wks = gc.open("data_test").sheet1

    cell_list = wks.range('A1')
    data = self.return_shapeshift_pairs_info()
    obj = json.loads(data)

    for cell in cell_list:
        cell.value = data
    wks.update_cells(cell_list)

 if __name__ == '__main__':
     app = Data()

如果我这样做:打印(self.return_shapeshift_pairs_info())

它返回所有可用的ShapeShift硬币符号

但我可以将其更新到我的Google电子表格中。我需要帮助如何将数据传递到正确的单元格。

谢谢!

0 个答案:

没有答案