teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

エラー内容を修正しました。

2019/10/09 02:05

投稿

raspypy
raspypy

スコア247

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 157, in <module>
13
+ File "5_BME280GDV.py", line 178, in <module>
14
- column_datas.append(datetime.now().strftime("%Y/%m/%d %H:%M:%S"))
14
+ column_datas.append("%7.2f" % (pressure/100))
15
- NameError: name 'datetime' is not defined
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/abc/xxx.json'
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('bme280_thp')
189
+ doc = gs.open('BME280')
188
- sheet = doc.worksheet("bme280")
190
+ sheet = doc.worksheet("BME280")
189
191
  sheet.append_row(column_datas)
190
192
 
191
193