Created
June 13, 2024 20:41
-
-
Save manutheblacker/26584d47a09c5a2482bf013997d01abe to your computer and use it in GitHub Desktop.
move a column of data to a specific position in openpyxl
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 os | |
import sys | |
from openpyxl import Workbook | |
def main(): | |
wb = Workbook() | |
ws1 = wb.active | |
ws1.title = "1st Hour" | |
ws1['A1'] = 'worry' | |
ws1['B1'] = 'worry' | |
ws1['C1'] = 'worry' | |
ws1.insert_cols( 2 ) | |
data1 = ['a','b', 'c', 'd', 'e'] | |
max = ws1.max_row | |
for row, entry in enumerate(data1, start=0): | |
ws1.cell(row=row+max, column=2, value=entry) | |
wb.save('FileName.xlsx') | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment