/ gsheet.ipynb
gsheet.ipynb
1 { 2 "cells": [ 3 { 4 "cell_type": "code", 5 "execution_count": 33, 6 "metadata": {}, 7 "outputs": [], 8 "source": [ 9 "import numpy as np\n", 10 "import pygsheets\n", 11 "import pandas as pd" 12 ] 13 }, 14 { 15 "cell_type": "code", 16 "execution_count": 14, 17 "metadata": {}, 18 "outputs": [], 19 "source": [ 20 "gc = pygsheets.authorize(service_account_file='sheetmanipulate.json')\n", 21 "url = 'https://docs.google.com/spreadsheets/d/1VTcDJa5cKIj2VjMC005flz7ESKDCPFAlH1QscYDPHv4/edit?usp=sharing'\n", 22 "sh = gc.open_by_url(url)" 23 ] 24 }, 25 { 26 "cell_type": "code", 27 "execution_count": 15, 28 "metadata": {}, 29 "outputs": [ 30 { 31 "data": { 32 "text/plain": [ 33 "<Spreadsheet 'grafana' Sheets:2>" 34 ] 35 }, 36 "execution_count": 15, 37 "metadata": {}, 38 "output_type": "execute_result" 39 } 40 ], 41 "source": [ 42 "sh " 43 ] 44 }, 45 { 46 "cell_type": "code", 47 "execution_count": 72, 48 "metadata": {}, 49 "outputs": [], 50 "source": [ 51 "ws = sh.worksheet_by_title('task')\n", 52 "#ws.update_value('A2', 'tttest')\n" 53 ] 54 }, 55 { 56 "cell_type": "code", 57 "execution_count": 48, 58 "metadata": {}, 59 "outputs": [], 60 "source": [ 61 "b = ws.find('tttest')" 62 ] 63 }, 64 { 65 "cell_type": "code", 66 "execution_count": 53, 67 "metadata": {}, 68 "outputs": [ 69 { 70 "data": { 71 "text/plain": [ 72 "<Cell B1 ''>" 73 ] 74 }, 75 "execution_count": 53, 76 "metadata": {}, 77 "output_type": "execute_result" 78 } 79 ], 80 "source": [ 81 "ws.cell((1,2))" 82 ] 83 }, 84 { 85 "cell_type": "code", 86 "execution_count": 74, 87 "metadata": {}, 88 "outputs": [], 89 "source": [ 90 "df1 = pd.DataFrame({'alpha':[0,1,2,3]})\n", 91 "df2 = pd.DataFrame({'beta':[0,1,2]})\n", 92 "ws.set_dataframe(df1, 'A1', copy_index=False, nan='')\n", 93 "ws.set_dataframe(df2, 'B1', copy_index=False, nan='')" 94 ] 95 }, 96 { 97 "cell_type": "code", 98 "execution_count": null, 99 "metadata": {}, 100 "outputs": [], 101 "source": [] 102 } 103 ], 104 "metadata": { 105 "kernelspec": { 106 "display_name": "v310", 107 "language": "python", 108 "name": "python3" 109 }, 110 "language_info": { 111 "codemirror_mode": { 112 "name": "ipython", 113 "version": 3 114 }, 115 "file_extension": ".py", 116 "mimetype": "text/x-python", 117 "name": "python", 118 "nbconvert_exporter": "python", 119 "pygments_lexer": "ipython3", 120 "version": "3.10.11" 121 } 122 }, 123 "nbformat": 4, 124 "nbformat_minor": 2 125 }