Skip to content

Commit

Permalink
implement
Browse files Browse the repository at this point in the history
  • Loading branch information
Haiss2 committed Aug 25, 2021
1 parent 48ab429 commit 4766964
Show file tree
Hide file tree
Showing 27 changed files with 1,091 additions and 18 deletions.
Binary file added __pycache__/ads_post_list.cpython-38.pyc
Binary file not shown.
Binary file added __pycache__/avg_each_type_of_post.cpython-38.pyc
Binary file not shown.
Binary file modified __pycache__/cover_page.cpython-38.pyc
Binary file not shown.
Binary file added __pycache__/d_o_d.cpython-38.pyc
Binary file not shown.
Binary file modified __pycache__/follower_analysis.cpython-38.pyc
Binary file not shown.
Binary file modified __pycache__/m_o_m.cpython-38.pyc
Binary file not shown.
Binary file added __pycache__/mention_ranking.cpython-38.pyc
Binary file not shown.
Binary file added __pycache__/post_list.cpython-38.pyc
Binary file not shown.
Binary file added __pycache__/stories_post_list.cpython-38.pyc
Binary file not shown.
Binary file added __pycache__/top_worst_post.cpython-38.pyc
Binary file not shown.
Binary file added __pycache__/top_worst_story.cpython-38.pyc
Binary file not shown.
16 changes: 16 additions & 0 deletions ads_post_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

import string
import datetime as dt

from openpyxl.styles import Border, Side, PatternFill, Font, GradientFill, Alignment
from openpyxl import Workbook


class AdsPostList():

def __init__(self, wb):
self.wb = wb

def render(self):
wb = self.wb
cover_page = wb.create_sheet("Ads Post List")
113 changes: 113 additions & 0 deletions avg_each_type_of_post.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import string
import datetime as dt

from openpyxl.styles import Border, Side, PatternFill, Font, GradientFill, Alignment
from openpyxl import Workbook
from openpyxl.chart import LineChart, Reference
from openpyxl.drawing.image import Image
from openpyxl.chart.axis import DateAxis

class AvgEachTypeOfPost():

def __init__(self, wb):
self.wb = wb
self.thin = Side(border_style="thin", color="000000")
self.border = Border(left=self.thin, right=self.thin, top=self.thin, bottom=self.thin)

def set_border(self, ws, cell_range):
rows = ws[cell_range]
for row in rows:
row[0].border = Border(left=self.thin)
row[-1].border = Border(right=self.thin)
for c in rows[0]:
c.border = Border(top=self.thin)
for c in rows[-1]:
c.border = Border(bottom=self.thin)
rows[0][0].border = Border(top=self.thin, left=self.thin)
rows[0][-1].border = Border(top=self.thin, right=self.thin)
rows[-1][0].border = Border(bottom=self.thin, left=self.thin)
rows[-1][-1].border = Border(bottom=self.thin, right=self.thin)


def render(self):
wb = self.wb
avg_each_type_post_list = wb.create_sheet("Avg of each type post")
avg_each_type_post_list.sheet_view.zoomScale = 85

for x in list(string.ascii_uppercase[0:9]):
avg_each_type_post_list.column_dimensions[x].width = 14

for merge_cells in ['A1:A2', 'B1:B2', 'C1:C2', 'D1:D2', 'E1:H1', 'I1:I2']:
avg_each_type_post_list.merge_cells(merge_cells)

data = [{
"type": "Carousel",
"number_of_posts": 10,
"reach": 445,
"impression": 500,
"like": 23,
"share": 45,
"comment": 34,
"total": 55,
"engagement_rate": 7.48,
}
for i in range(3)]

for y in range(3, 3 + len(data)):
avg_each_type_post_list.row_dimensions[y].height = 40
avg_each_type_post_list.row_dimensions[1].height = 25
avg_each_type_post_list.row_dimensions[2].height = 25


for row in avg_each_type_post_list['A1:I{}'.format(len(data)+2)]:
for cell in row:
cell.border = self.border

headers = [
{ "label": "Type", "pos": "A1"},
{ "label": "Number of posts", "pos": "B1"},
{ "label": "Reach", "pos": "C1"},
{ "label": "Impression", "pos": "D1"},
{ "label": "Engagement", "pos": "E1"},
{ "label": "Likes", "pos": "E2"},
{ "label": "Comments", "pos": "F2"},
{ "label": "Shares", "pos": "G2"},
{ "label": "Total", "pos": "H2"},
{ "label": "Engagement Rate", "pos": "I1"},

]

for header in headers:
cell = avg_each_type_post_list[header["pos"]]
cell.alignment = Alignment(horizontal="center", vertical="center")
cell.font = Font(b=True, color="00FFFFFF", size=12)
cell.fill = PatternFill("solid", fgColor="003366FF")
cell.value = header["label"]

for i, row in enumerate(data):
avg_each_type_post_list['A{}'.format(3+i)].value = row["type"]
avg_each_type_post_list['B{}'.format(3+i)].value = row["number_of_posts"]
avg_each_type_post_list['C{}'.format(3+i)].value = row["reach"]
avg_each_type_post_list['D{}'.format(3+i)].value = row["impression"]
avg_each_type_post_list['E{}'.format(3+i)].value = row["like"]
avg_each_type_post_list['F{}'.format(3+i)].value = row["comment"]
avg_each_type_post_list['G{}'.format(3+i)].value = row["share"]
avg_each_type_post_list['H{}'.format(3+i)].value = row["total"]
avg_each_type_post_list['I{}'.format(3+i)].value = row["engagement_rate"]

for letter in ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I']:
avg_each_type_post_list['{}{}'.format(letter, 3+i)].alignment = Alignment(vertical="center", horizontal="right")


# Notions
note_row = len(data) + 4
avg_each_type_post_list['G' + str(note_row)].value = "※1 Stories are not included."

avg_each_type_post_list.merge_cells('A{}:A{}'.format(len(data) + 6, len(data) + 8))
cmt = avg_each_type_post_list['A{}'.format(len(data) + 6)]
cmt.value = 'Comments'
avg_each_type_post_list.merge_cells('B{}:I{}'.format(len(data) + 6, len(data) + 8))
self.set_border(avg_each_type_post_list, 'B{}:I{}'.format(len(data) + 6, len(data) + 8))
cmt.alignment = Alignment(horizontal="center", vertical="center")
cmt.font = Font(b=True, color="00FFFFFF", size=12)
cmt.fill = PatternFill("solid", fgColor="003366FF")
3 changes: 1 addition & 2 deletions cover_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

from openpyxl.styles import Border, Side, PatternFill, Font, GradientFill, Alignment
from openpyxl import Workbook
from openpyxl.chart import PieChart, ProjectedPieChart, Reference
from openpyxl.chart.series import DataPoint


class CoverPage():

Expand Down
108 changes: 108 additions & 0 deletions d_o_d.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import string
import datetime as dt

from openpyxl.styles import Border, Side, PatternFill, Font, GradientFill, Alignment
from openpyxl import Workbook
from openpyxl.chart import LineChart, Reference
from openpyxl.drawing.image import Image
from openpyxl.chart.axis import DateAxis

class DoD():

def __init__(self, wb):
self.wb = wb
self.thin = Side(border_style="thin", color="000000")
self.border = Border(left=self.thin, right=self.thin, top=self.thin, bottom=self.thin)

def set_border(self, ws, cell_range):
rows = ws[cell_range]
for row in rows:
row[0].border = Border(left=self.thin)
row[-1].border = Border(right=self.thin)
for c in rows[0]:
c.border = Border(top=self.thin)
for c in rows[-1]:
c.border = Border(bottom=self.thin)
rows[0][0].border = Border(top=self.thin, left=self.thin)
rows[0][-1].border = Border(top=self.thin, right=self.thin)
rows[-1][0].border = Border(bottom=self.thin, left=self.thin)
rows[-1][-1].border = Border(bottom=self.thin, right=self.thin)

def render_grid(self, ws, title, col_index, chart_where):
# chart here
c1 = LineChart()
c1.width = 18
c1.height = 9
c1.style = 13
c1.title = title

labels = Reference(ws, min_row=3, max_row=35,min_col=1)
data = Reference(ws, min_row=2, max_row=35,min_col=col_index)

c1.add_data(data, titles_from_data=True)
c1.set_categories(labels)

ws.add_chart(c1, chart_where)

def render(self):
wb = self.wb
d_o_d = wb.create_sheet("DoD")
d_o_d.sheet_view.zoomScale = 70

for x in list(string.ascii_uppercase[2:]):
d_o_d.column_dimensions[x].width = 16
for y in range(3, 60):
d_o_d.row_dimensions[y].height = 27
d_o_d.row_dimensions[1].height = 45
d_o_d.row_dimensions[2].height = 45

for merge_cells in ['A1:H1', 'A39:C41', 'D39:V41']:
d_o_d.merge_cells(merge_cells)

d_o_d['A1'].value = '2021/8'
d_o_d['A1'].font = Font(b=True, size=18)
d_o_d['A1'].alignment = Alignment(horizontal="left", vertical="center")

data = [
['1 日', 'Sat', 1078 ,'-', 5 , 0, 114, 131],
['2 日', 'Sun', 1078 ,0 , 4, 0, 26, 31 ],
['3 日', 'Mon', 1078 ,0 , 0, 0, 18, 19 ],
['4 日', 'Tue', 1078 ,0 , 7, 0, 144, 164 ],
['5 日', 'Wed', 1078 ,1, 12, 0, 41, 58 ],
['6 日', 'Thu', 1078 ,1 , 1, 0, 31, 33 ],
['7 日', 'Fri', 1078 ,2 , 11, 0, 139, 179 ],
]
data = [*data,*data,*data,*data,['29 日', 'Thu', '1,078','1' , '1', '0', '31', '33' ],['30 日', 'Fri', '1,080','2' , '11', '0', '139', '179' ], ['31 日', 'Fri', '1,080','2' , '11', '0', '139', '179' ]]
headers = ['Day', 'Date', 'Follower', 'Follower\n(+/-)', 'Profile View', 'Website\nClicks', 'Reach', 'Impression']

self.set_border(d_o_d, 'A3:H33')

for index, header in enumerate(headers):
element = d_o_d[string.ascii_uppercase[index] + str(2)]
element.alignment = Alignment(horizontal="center", vertical="center", wrap_text=True)
element.value = header
element.font = Font(b=True, color="00FFFFFF")
element.fill = PatternFill("solid", fgColor="003366FF")

for i, row in enumerate(data):
for j, cell in enumerate(row):
el = d_o_d[string.ascii_uppercase[j] + str(3+i)]
el.value = cell
el.number_format = 'General'
el.alignment = Alignment(horizontal="right", vertical="center")

self.render_grid(d_o_d, 'Follower', 3, 'J2')
self.render_grid(d_o_d, 'Follower (+/-)', 4, 'Q2')
self.render_grid(d_o_d, 'Profile View', '5', 'J12')
self.render_grid(d_o_d, 'Website Clicks', 6, 'Q12')
self.render_grid(d_o_d, 'Reach', 7, 'J23')
self.render_grid(d_o_d, 'Impression', 8, 'Q23')

d_o_d['K34'].value = '※1 The figure of Follower & Follower (+/-) can only be shown since the day your acc is connected with Reposta'
d_o_d['K35'].value = '※2 The figure includes the advertisement as well.'

d_o_d['A39'].value = 'Comments'
self.set_border(d_o_d, 'D39:V41')
d_o_d['A39'].alignment = Alignment(horizontal="center", vertical="center")
d_o_d['A39'].font = Font(b=True, color="00FFFFFF", size=12)
d_o_d['A39'].fill = PatternFill("solid", fgColor="003366FF")
3 changes: 1 addition & 2 deletions follower_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

from openpyxl.styles import Border, Side, PatternFill, Font, GradientFill, Alignment
from openpyxl import Workbook
from openpyxl.chart import PieChart, ProjectedPieChart, Reference, BarChart
from openpyxl.chart.series import DataPoint
from openpyxl.chart import PieChart, Reference, BarChart

class FollowerAnalysis():

Expand Down
Binary file added img/post.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added img/stories.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4766964

Please sign in to comment.