Last active
January 27, 2024 11:23
-
-
Save OlegKorn/1cf8befa67ea44cdb1f5471ca5fade28 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import openpyxl | |
# maybe in loop | |
for i in data: # let i == [a, b] | |
df = pd.DataFrame( | |
[[a, b]], | |
columns=['Title1', 'Title2'] | |
) | |
with pd.ExcelWriter( | |
"title.xlsx", | |
mode="a", # append instead of making new each time | |
engine="openpyxl", | |
if_sheet_exists="overlay" # idk | |
) as writer: | |
df.to_excel( | |
writer, | |
sheet_name="new_sheet_name", | |
header=None, | |
startrow=writer.sheets["new_sheet_name"].max_row, | |
index=False | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment