Skip to content

Instantly share code, notes, and snippets.

@manutheblacker
Created June 13, 2024 20:41
Show Gist options
  • Save manutheblacker/26584d47a09c5a2482bf013997d01abe to your computer and use it in GitHub Desktop.
Save manutheblacker/26584d47a09c5a2482bf013997d01abe to your computer and use it in GitHub Desktop.
move a column of data to a specific position in openpyxl
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