JPLTedCas commited on
Commit
1173aa1
·
1 Parent(s): 5f28c16

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +67 -0
app.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+
4
+
5
+
6
+ from PIL import Image
7
+ image = Image.open('KYB.png')
8
+ st.image(image, caption='Powered by TedCas')
9
+
10
+
11
+ uploaded_file = st.file_uploader("Choose product file", type="csv")
12
+
13
+ if uploaded_file:
14
+ df = pd.read_csv(uploaded_file, delimiter=';', encoding='utf8')
15
+ import numpy as np
16
+
17
+ #select only the numeric columns in the DataFrame
18
+ dfnumeric=df.select_dtypes(include=np.number)
19
+
20
+
21
+
22
+
23
+ def write_excel(data,date):
24
+
25
+
26
+ # Python3 code to select
27
+ # data from excel
28
+ import xlwings as xw
29
+
30
+ # Specifying a sheet
31
+ ws = xw.Book("07-253-b Estudio capacidad (con grafico).xls").sheets['DATOS']
32
+
33
+ # Selecting data from
34
+ # a single cell
35
+ v1 = ws.range("A1:A7").value
36
+ # v2 = ws.range("F5").value
37
+ print("Result:", v1)
38
+ length=len(data)
39
+ for i in range(len(date)):
40
+ #ws.range(9+i,0).value = date[i]
41
+ #ws.range(9+i,1).value = data[i]
42
+ #ws.range(1,0).value = "pepe"
43
+ ws.range("A"+str(9+i)).value = date[i]
44
+ ws.range("B"+str(9+i)).value = data[i]
45
+
46
+ def KYBConvert(df,make_choice):
47
+ #INPUT FILE
48
+
49
+ df.to_excel('export.xlsx',index=False)
50
+
51
+ date=pd.to_datetime(df.iloc[:,1], format="%y%m%d-%H:%M")
52
+ #data=pd.Series(df.iloc[:,4],dtype="int")
53
+ data=pd.Series(df.loc[:,make_choice],dtype="int")
54
+
55
+ write_excel(data,date)
56
+
57
+
58
+
59
+ if uploaded_file:
60
+ st.dataframe(dfnumeric)
61
+ makes = df.select_dtypes([np.number]).columns
62
+ make_choice = st.sidebar.selectbox('Select cathegory:', makes)
63
+ print(make_choice)
64
+ if make_choice!='ID':
65
+ KYBConvert(df,make_choice)
66
+ st.write("Puedes encontrar tu excel en: C:/Users/15572890/Desktop/I+D/ProyectosPython/KYB/07-253-b Estudio capacidad (con grafico).xls")
67
+