-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPyVertex.py
53 lines (46 loc) · 1.28 KB
/
PyVertex.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- coding: utf-8 -*-
"""
Created on Fri Feb 26 12:51:27 2016
@author: user11
"""
import os
import glob
import xlwings as xw
import numpy as np
import pandas as pd
color_OK = (208, 254, 182)
color_NOK = (236, 181, 167)
path = os.getcwd()
path = "G:/01-SUIVI PROCESSUS/GMM/Micro-Vu Vertex/Schrader/43173-820"
fcsv = glob.glob(path+"/CSV Data/*.txt")[0] # File containing CSV
os.system("pause")
fxls = glob.glob(path+"/Layout/*.xlsx")[0] # xlsx file layout for report
os.system("pause")
# print(fcsv,fxls)
# os.system("pause")
def file2df(fname):
"""CSV import function"""
data = pd.read_csv(fname, header=None,
sep=None,
index_col=False)
return data
wb = xw.Workbook(fxls)
data = file2df(fcsv)
for index, row in data.iterrows():
# os.system("pause")
loc = data[0][index]
value = data[1][index]
if np.isnan(data[4][index]):
if np.isnan(data[3][index]):
color = color_OK
else:
color = color_NOK
elif np.isnan(data[6][index]):
color = color_OK
else:
color = color_NOK
xw.Range(str(loc)).value = value
xw.Range(str(loc)).color = color
wb.xl_workbook.PrintOut()
# os.system("pause")
wb.close()