import pandas as pd import openpyxl aaaa = ['AAAAA','AAAA','AAA','AA','A'] ap_01 = [len(qq) for qq in aaaa] print(ap_01) iiii = "sososo" ap_len_pd = pd.DataFrame(ap_01, columns=[iiii]) ap_ww_pd = pd.DataFrame(ap_01, columns=[iiii]) print(ap_len_pd) saka = ['iwiwi','qoqo'] with pd.ExcelWriter('indas.xlsx', engine="openpyxl") as writer: for i in saka: ap_len_pd.to_excel(writer, sheet_name=i, index=False) ap_ww_pd.to_excel(writer, sheet_name=i, index=False)
上記だと上手くいくのですが、
import pandas as pd import openpyxl notation_list = ["A","B","C","D"] 色々あって exec(f"{ano_mp}_len_pd = pd.DataFrame(ai_02, columns=[ano_mp])") print(1) with pd.ExcelWriter('length_id_summary.xlsx', engine="openpyxl") as writer: for ano_pd in anotation_list: print(ano_pd) exec(f"ai_03 = {ano_pd}_len_pd") ai_03.to_excel(writer, sheet_name=ano_pd)
のようなスクリプトだと
raise IndexError("At least one sheet must be visible")
IndexError: At least one sheet must be visible
失礼いたしました。
以下エラー全文です
Traceback (most recent call last): File "/var/spool/ge/yc066i/job_scripts/17800332", line 54, in <module> nounal_len_pd.to_excel(writer, sheet_name='genome') File "/home/name/.local/lib/python3.6/site-packages/pandas/core/generic.py", line 2181, in to_excel engine=engine, File "/home/name/.local/lib/python3.6/site-packages/pandas/io/formats/excel.py", line 719, in write f"This sheet is too large! Your sheet size is: {num_rows}, {num_cols} " ValueError: This sheet is too large! Your sheet size is: 34430947, 1 Max sheet size is: 1048576, 16384 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/var/spool/ge/yc066i/job_scripts/17800332", line 66, in <module> all_no_len_pd.to_excel(writer, sheet_name='all_no') File "/home/name/.local/lib/python3.6/site-packages/pandas/io/excel/_base.py", line 777, in __exit__ self.close() File "/home/name/.local/lib/python3.6/site-packages/pandas/io/excel/_base.py", line 781, in close return self.save() File "/home/name/.local/lib/python3.6/site-packages/pandas/io/excel/_openpyxl.py", line 43, in save return self.book.save(self.path) File "/home/name/.local/lib/python3.6/site-packages/openpyxl/workbook/workbook.py", line 392, in save save_workbook(self, filename) File "/home/name/.local/lib/python3.6/site-packages/openpyxl/writer/excel.py", line 293, in save_workbook writer.save() File "/home/name/.local/lib/python3.6/site-packages/openpyxl/writer/excel.py", line 275, in save self.write_data() File "/home/name/.local/lib/python3.6/site-packages/openpyxl/writer/excel.py", line 89, in write_data archive.writestr(ARC_WORKBOOK, writer.write()) File "/home/name/.local/lib/python3.6/site-packages/openpyxl/workbook/_writer.py", line 148, in write self.write_views() File "/home/name/.local/lib/python3.6/site-packages/openpyxl/workbook/_writer.py", line 135, in write_views active = get_active_sheet(self.wb) File "/home/name/.local/lib/python3.6/site-packages/openpyxl/workbook/_writer.py", line 33, in get_active_sheet raise IndexError("At least one sheet must be visible") IndexError: At least one sheet must be visible
というエラーが出て、最初のprint(1)は全て出力されており、pandasのDataFrameまでは大丈夫なのは確認したのですが、
ExcelWriterの部分で、prin(ano_pd)でAは出力されているのですが、それ以降が出力されていない状態です。出来たExcel fileも壊れていて開ません。
途方に暮れています。
お願い申し上げます。
回答1件
あなたの回答
tips
プレビュー