質問編集履歴

2

修正

2020/09/09 07:42

投稿

ab7651
ab7651

スコア2

test CHANGED
File without changes
test CHANGED
@@ -108,7 +108,7 @@
108
108
 
109
109
  15 df["i"] = pd.DataFrame(dataList,columns=columns)
110
110
 
111
- ---> 16 with pd.ExcelWriter("店舗別売上別リスト.xlsx",data_format='YYYY/MM/DD',datatime_format='YYYY/MM/DD',engine="openpyxl",mode='a')as writer:
111
+ ---> 16 with pd.ExcelWriter("新サンプル.xlsx",data_format='YYYY/MM/DD',datatime_format='YYYY/MM/DD',engine="openpyxl",mode='a')as writer:
112
112
 
113
113
  17 df["i"].to_excel(writer,sheet_name="i",index=False)
114
114
 

1

コードを入力し直しました。エラーメッセージを全て載せました。

2020/09/09 07:42

投稿

ab7651
ab7651

スコア2

test CHANGED
File without changes
test CHANGED
@@ -98,95 +98,137 @@
98
98
 
99
99
 
100
100
 
101
+ ```---------------------------------------------------------------------------
102
+
103
+ FileNotFoundError Traceback (most recent call last)
104
+
105
+ <ipython-input-80-547f5f2e3ff5> in <module>
106
+
107
+ 14 for i in suppliers:
108
+
109
+ 15 df["i"] = pd.DataFrame(dataList,columns=columns)
110
+
111
+ ---> 16 with pd.ExcelWriter("店舗別売上別リスト.xlsx",data_format='YYYY/MM/DD',datatime_format='YYYY/MM/DD',engine="openpyxl",mode='a')as writer:
112
+
113
+ 17 df["i"].to_excel(writer,sheet_name="i",index=False)
114
+
115
+
116
+
117
+ ~\anaconda3\lib\site-packages\pandas\io\excel\_openpyxl.py in __init__(self, path, engine, mode, **engine_kwargs)
118
+
119
+ 23 from openpyxl import load_workbook
120
+
121
+ 24
122
+
123
+ ---> 25 book = load_workbook(self.path)
124
+
125
+ 26 self.book = book
126
+
127
+ 27 else:
128
+
129
+
130
+
131
+ ~\anaconda3\lib\site-packages\openpyxl\reader\excel.py in load_workbook(filename, read_only, keep_vba, data_only, keep_links)
132
+
133
+ 311 """
134
+
135
+ 312 reader = ExcelReader(filename, read_only, keep_vba,
136
+
137
+ --> 313 data_only, keep_links)
138
+
139
+ 314 reader.read()
140
+
141
+ 315 return reader.wb
142
+
143
+
144
+
145
+ ~\anaconda3\lib\site-packages\openpyxl\reader\excel.py in __init__(self, fn, read_only, keep_vba, data_only, keep_links)
146
+
147
+ 122 def __init__(self, fn, read_only=False, keep_vba=KEEP_VBA,
148
+
149
+ 123 data_only=False, keep_links=True):
150
+
151
+ --> 124 self.archive = _validate_archive(fn)
152
+
153
+ 125 self.valid_files = self.archive.namelist()
154
+
155
+ 126 self.read_only = read_only
156
+
157
+
158
+
159
+ ~\anaconda3\lib\site-packages\openpyxl\reader\excel.py in _validate_archive(filename)
160
+
161
+ 94 raise InvalidFileException(msg)
162
+
163
+ 95
164
+
165
+ ---> 96 archive = ZipFile(filename, 'r')
166
+
167
+ 97 return archive
168
+
169
+ 98
170
+
171
+
172
+
173
+ ~\anaconda3\lib\zipfile.py in __init__(self, file, mode, compression, allowZip64, compresslevel)
174
+
175
+ 1238 while True:
176
+
177
+ 1239 try:
178
+
179
+ -> 1240 self.fp = io.open(file, filemode)
180
+
181
+ 1241 except OSError:
182
+
183
+ 1242 if filemode in modeDict:
184
+
185
+
186
+
187
+ FileNotFoundError: [Errno 2] No such file or directory: '"新サンプル".xlsx'
188
+
101
- ```
189
+ ```
102
-
103
- "新サンプル.xlsx"がno such・・・になってしまう。
190
+
104
-
105
- ```
191
+ ```python
106
-
107
-
108
-
109
-
110
192
 
111
193
  import pandas as pd
112
194
 
113
-
114
-
115
195
  import os
116
196
 
117
-
118
-
119
197
  df = pd.read_excel("サンプル.xlsx",sheet_name="Sheet1")
120
198
 
121
-
122
-
123
199
  dateList = []
124
200
 
125
-
126
-
127
201
  suppliers = []
128
202
 
129
-
130
-
131
203
  columns = list(df.columns)
132
204
 
133
-
134
-
135
205
  sheetsList=list(df.keys())
136
206
 
137
-
138
-
139
207
  for index , rows in df.iterrows():
140
208
 
141
-
142
-
143
- work = []
144
-
145
-
146
-
147
- for row in rows:
209
+ for row in rows:
148
-
149
-
150
-
210
+
151
- work.append(row)
211
+ work.append(row)
152
-
153
-
154
-
212
+
155
- cell_value = df.iloc[:,1]
213
+ cell_value = df.iloc[:,1]
156
-
157
-
158
-
214
+
159
- if cell_value in suppliers:
215
+ if cell_value in suppliers:
160
-
161
-
162
-
216
+
163
- suppliers.append(cell_value)
217
+ suppliers.append(cell_value)
164
-
165
-
166
218
 
167
219
  for i in suppliers:
168
220
 
169
-
170
-
171
- df["i"] = pd.DataFrame(dataList,columns=columns)
221
+ df["i"] = pd.DataFrame(dataList,columns=columns)
172
-
173
-
174
222
 
175
223
  with pd.ExcelWriter("新サンプル.xlsx",data_format='YYYY/MM/DD',datatime_format='YYYY/MM/DD',engine="openpyxl",mode='a')as writer:
176
224
 
177
-
178
-
179
- df["i"].to_excel(writer,sheet_name="i",index=False)
225
+ df["i"].to_excel(writer,sheet_name="i",index=False)
180
-
181
-
182
-
183
-
184
-
185
- ```ここに言語名を入力
226
+
186
-
187
- python
188
-
189
- ```
227
+ ```
228
+
229
+
230
+
231
+
190
232
 
191
233
 
192
234
 
@@ -194,7 +236,7 @@
194
236
 
195
237
 
196
238
 
197
- ここに問題に対して試したことを記載してください。
239
+
198
240
 
199
241
 
200
242
 
@@ -202,4 +244,10 @@
202
244
 
203
245
 
204
246
 
247
+ python3.
248
+
205
- ここにより詳細な情報記載してください
249
+ anaconda使用しております
250
+
251
+ python自体はドがつく素人でVBAをちょっとかじっているレベルです。
252
+
253
+ pandasとopenpyxlの使い分けは分析 = pandas エクセル操作 = openpyxl の様なイメージで良いのでしょうか?