Skip to content

Instantly share code, notes, and snippets.

@DDSNA
Created April 30, 2021 11:49
Show Gist options
  • Save DDSNA/2c49c313ee6985fd02806cd8af5633ca to your computer and use it in GitHub Desktop.
Save DDSNA/2c49c313ee6985fd02806cd8af5633ca to your computer and use it in GitHub Desktop.
import openpyxl as xl
from openpyxl.chart import BarChart, reference
def process_workbook(filename):
wb = xl.load_workbook(filename)
sheet = wb["Sheet1"]
for row in range (2, sheet.max_row +1):
cell=sheet.cell(row, 3)
corrected_price = cell.value*0.9
corrected_price_cell = sheet.cell(row, 4)
corrected_price_cell.value = corrected_price
wb.save('edited_excel_file_automated.xlsx')
process_workbook('transactions.xlsx')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment