admin管理员组文章数量:1122832
I am very new to Python and getting an error that I can't seem to resolve. In my Python script I am querying a Snowflake database and then turning the results into a dataFrame (df). Following this, I simply write an .xlsx file.
This all works fine until I open the Excel file. I'm greeted by a message "We found a problem with some content in the ‘file.XLSX’. Do you want us to try to recover as much as we can?" Upon clicking "yes" the file contains all of the data in a repaired version of the file. The log of repairs is as follows "Removed Records: Formula from /xl/worksheets/sheet1.xml part"
I've tried to leverage a number of solutions with no luck. I experimented with using xlwings and cleaning my columns to strip any potential leading "=". Again, I'm new to Python so I don't really know where to go from here.
import os
import snowflake.connector
import pandas as pd
from openpyxl import load_workbook
#SQL Code - Removed for Privacy
# Execute the query
cursor_clm_dm = conn_clm_dm.cursor()
cursor_clm_dm.execute(query)
# Fetch the results
results = cursor_clm_dm.fetchall()
# Convert the results to a Pandas DataFrame
columns = [desc[0] for desc in cursor_clm_dm.description]
df = pd.DataFrame(results, columns=columns)
# Close the cursor and connection
cursor_clm_dm.close()
conn_clm_dm.close()
conn_clm_dw.close()
# Display the DataFrame
print(df)
df.to_excel('C:\\Users\\JohnG\\Downloads\\file.xlsx', index=False)
print('done')
本文标签:
版权声明:本文标题:pandas - Why am I getting this error "Removed Records: Formula from xlworksheetssheet2.xml part" when writing 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736302795a1931660.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论