質問編集履歴
1
エラー内容を修正しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -10,9 +10,9 @@
|
|
10
10
|
##エラー内容
|
11
11
|
```html
|
12
12
|
Traceback (most recent call last):
|
13
|
-
File "5_BME280GDV.py", line
|
13
|
+
File "5_BME280GDV.py", line 178, in <module>
|
14
|
-
column_datas.append(
|
14
|
+
column_datas.append("%7.2f" % (pressure/100))
|
15
|
-
NameError: name '
|
15
|
+
NameError: name 'pressure' is not defined
|
16
16
|
```
|
17
17
|
|
18
18
|
##プログラムコード
|
@@ -168,6 +168,8 @@
|
|
168
168
|
import gspread
|
169
169
|
from oauth2client.service_account import ServiceAccountCredentials
|
170
170
|
|
171
|
+
from datetime import datetime
|
172
|
+
|
171
173
|
column_datas = []
|
172
174
|
|
173
175
|
def read_data():
|
@@ -178,14 +180,14 @@
|
|
178
180
|
|
179
181
|
def write_data():
|
180
182
|
global column_datas
|
181
|
-
filename = '/home/pi/
|
183
|
+
filename = '/home/pi/xxx/abcde.json'
|
182
184
|
client_email = "abcdef@gmail.com"
|
183
185
|
with open(filename) as f: private_key = f.read()
|
184
186
|
scopes = ['https://spreadsheets.google.com/feeds/', 'https://docs.google.com/feeds']
|
185
187
|
credentials = ServiceAccountCredentials.from_json_keyfile_name(filename, scopes)
|
186
188
|
gs = gspread.authorize(credentials)
|
187
|
-
doc = gs.open('
|
189
|
+
doc = gs.open('BME280')
|
188
|
-
sheet = doc.worksheet("
|
190
|
+
sheet = doc.worksheet("BME280")
|
189
191
|
sheet.append_row(column_datas)
|
190
192
|
|
191
193
|
|