質問編集履歴

2

書式の改善

2018/10/28 10:41

投稿

Majespy
Majespy

スコア22

test CHANGED
File without changes
test CHANGED
@@ -66,6 +66,8 @@
66
66
 
67
67
  ```
68
68
 
69
+ エラー例①
70
+
69
71
  ```Python
70
72
 
71
73
  sheets = wb.sheets()
@@ -92,7 +94,7 @@
92
94
 
93
95
  ```
94
96
 
95
-
97
+ エラー例②
96
98
 
97
99
  ```Python
98
100
 

1

numpy配列の初期化処理の前行追加

2018/10/28 10:41

投稿

Majespy
Majespy

スコア22

test CHANGED
File without changes
test CHANGED
@@ -31,6 +31,40 @@
31
31
  ④は完成イメージです。
32
32
 
33
33
  ### エラーメッセージ・該当のソースコード
34
+
35
+ ```Python
36
+
37
+ if request.method == 'POST':
38
+
39
+   file = request.files['file']
40
+
41
+   UPLOAD_FOLDER = r'C:\xxx\xxx\xxx\TestProject\uploads'
42
+
43
+   app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
44
+
45
+  if file:
46
+
47
+ filename = secure_filename(file.filename)
48
+
49
+ file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
50
+
51
+ wb = xlrd.open_workbook(r"C:\xxx\xxx\xxx\TestProject\uploads\test.xlsx")
52
+
53
+ sheets = wb.sheets()
54
+
55
+ month = np.array(sheets['Sheet1'].cell(row=i, column=0).value for i in range(1, 13))
56
+
57
+ sale = np.array(sheets['Sheet1'].cell(row=i, column=1).value for i in range(1, 13))
58
+
59
+ cost = np.array(sheets['Sheet1'].cell(row=i, column=2).value for i in range(1, 13))
60
+
61
+ benefit = sale - cost
62
+
63
+ #プロットの処理が続く
64
+
65
+
66
+
67
+ ```
34
68
 
35
69
  ```Python
36
70
 
@@ -118,19 +152,7 @@
118
152
 
119
153
 
120
154
 
121
- numpy配列の初期化に問題があると考え、幾通りか試してみました。
122
155
 
123
- ```Python
124
-
125
- month = np.array([sheets['Sheet1'].cell(row=i, column=0).value for i in range(1, 13)])
126
-
127
- month = np.array(sheets['Sheet1'].cell(row=i, column=0).value for i in range(1, 13))
128
-
129
- month = np.array([sheets['Sheet1'].cell(row=i, column=0).value for i in range(1, sheets['Sheet1'].max_row)])
130
-
131
- month = np.array(sheets['Sheet1'].cell(row=i, column=0).value for i in range(1, sheets['Sheet1'].max_row))
132
-
133
- ```
134
156
 
135
157
 
136
158