-
Notifications
You must be signed in to change notification settings - Fork 0
/
file_treatment.py
38 lines (29 loc) · 1.13 KB
/
file_treatment.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from openpyxl import load_workbook
import csv
import openpyxl
from openpyxl.styles import Font
def change_csv_to_xlsx(name):#изменяет csv yf xlsx
wb = openpyxl.Workbook()
ws = wb.active
with open(name) as f:
reader = csv.reader(f, delimiter=',')
for row in reader:
ws.append(row)
wb.save(name.replace('csv', 'xlsx'))
def draw(name):#изменяет цвет ячейки по условию
name = name.replace('csv', 'xlsx')
wb_file = load_workbook(name) # , data_only=True)
ws_file = wb_file.active
sheet_form = wb_file["Sheet"]
# sheet_form["A1"].value = "Link"
k = 0
for iter, value in enumerate(sheet_form.values):
if iter == 0:
continue
if value[11] != "Не указано" and int(value[11].replace(" ", "")) - int(
value[7].replace(" ", "")) > 1000000: # Изменение цены
k += 1
a = ws_file["A" + str(iter + 1)]
a.font = Font(color="FF0000")
print("Количество объявлений которые подешевели ", k)
wb_file.save(name)