ValueError:此工作表太大!您的图纸尺寸是:1220054,3最大图纸尺寸是:1048576,16384 [英] ValueError: This sheet is too large! Your sheet size is: 1220054, 3 Max sheet size is: 1048576, 16384
问题描述
我正在尝试将 .txt
文件转换为excel文件,但是遇到以下错误:
I am trying to convert a .txt
file to an excel file and I encountered the below error:
Traceback (most recent call last):
File "C:/Users/haroo501/PycharmProjects/MyLiveRobo/convert_txt_csv.py", line 13, in <module>
dataf_umts_txt_df.to_excel('umtsrelation_mnm.xlsx', 'Sheet1', index=False)
File "C:\Users\haroo501\PycharmProjects\MyLiveRobo\venv\lib\site-packages\pandas\core\generic.py", line 2250, in to_excel
formatter.write(
File "C:\Users\haroo501\PycharmProjects\MyLiveRobo\venv\lib\site-packages\pandas\io\formats\excel.py", line 721, in write
raise ValueError(
ValueError: This sheet is too large! Your sheet size is: 1220054, 3 Max sheet size is: 1048576, 16384
Process finished with exit code 1
这是我的代码:
import pandas as pd
import os
hua_umts_dataf_rel_txt = 'umtsrelation_mnm.txt'
dataf_umts_txt_df = pd.read_csv(hua_umts_dataf_rel_txt, sep=';')
hua_umts_dataf_rel_df_column_index = list(dataf_umts_txt_df.columns)
dataf_umts_txt_df.reset_index(inplace=True)
dataf_umts_txt_df.drop(columns=dataf_umts_txt_df.columns[-1], inplace=True)
hua_umts_dataf_rel_df_column_index = dict(zip(list(dataf_umts_txt_df.columns), hua_umts_dataf_rel_df_column_index))
dataf_umts_txt_df.rename(columns=hua_umts_dataf_rel_df_column_index, inplace=True)
dataf_umts_txt_df.to_excel('umtsrelation_mnm.xlsx', 'Sheet1', index=False)
print(hua_umts_dataf_rel_txt)
有人对此有解决方案吗?我只是想先将 txt
文件转换为excel文件,然后再将其推入 sql
.
Anyone have solution for this? I am just trying to convert txt
file into excel file before pushing it to sql
.
推荐答案
您可以尝试将其转换为csv而不是excel,当在excel中打开时,它几乎具有相同的用途,但不能使用公式或多张工作表.第二种选择是将数据框分为两部分,或者将它们分成尽可能多的部分,然后将它们全部推送到sql
You can try converting it to csv instead of excel which when opened in excel gives almost the same use except that you cannot use formulas or multiple sheets. The second option is dividing the data frame into two parts or as many you feel comfortable and then push all of them to sql
这篇关于ValueError:此工作表太大!您的图纸尺寸是:1220054,3最大图纸尺寸是:1048576,16384的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!