Skip to content

Commit

Permalink
created transactions2.xlsx to store the results of data management fr…
Browse files Browse the repository at this point in the history
…om transactions.xlsx. on using_pip_openpyxl, made an an exercise on this. need to apply 10% discount on all the values under C column. Made a chart. This is just a practice to familiarize myself with the Python packages available on the Python Package Index. myself with its available functionalities
  • Loading branch information
mynameisrhay committed Nov 5, 2023
1 parent cd888b9 commit 3790d85
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Binary file added transactions2.xlsx
Binary file not shown.
23 changes: 21 additions & 2 deletions using_pip_openpyxl.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# Will make an exercise on this. need to apply 10% discount on all the values under C column.
# Also need to make a chart once done.
# This is just a practice to familiarize myself with the Python packages available on the Python Package Index.
# I clearly need to delve much deeper into a specific Python package if I want to familiarize
# myself with its available functionalities

import openpyxl as xl
from openpyxl.chart import BarChart, Reference

wb = xl.load_workbook("transactions.xlsx")
sheet = wb['Sheet1']
cell = sheet.cell(1, 1)
Expand All @@ -13,5 +21,16 @@

print("will reiterate the contents of C2 to C4 cells below:")
for row in range(2, max_row + 1):
cell = sheet.cell(row, 3)
print(cell.value)
cell_column_c = sheet.cell(row, 3)
discounted_price = cell_column_c.value * .90
cell_column_d = sheet.cell(row, 4)
cell_column_d.value = discounted_price

ref_values = Reference(sheet, min_row=2, max_row=sheet.max_row, min_col=4, max_col=4)

chart = BarChart()
chart.add_data(ref_values)
sheet.add_chart(chart, 'e2')

wb.save('transactions2.xlsx')
print("Saved on transactions2.xlsx")

0 comments on commit 3790d85

Please sign in to comment.