|
|
import streamlit as st |
|
|
import pandas as pd |
|
|
|
|
|
|
|
|
|
|
|
from PIL import Image |
|
|
image = Image.open('KYB.png') |
|
|
st.image(image, caption='Powered by TedCas') |
|
|
|
|
|
|
|
|
uploaded_file = st.file_uploader("Choose product file", type="csv") |
|
|
|
|
|
if uploaded_file: |
|
|
df = pd.read_csv(uploaded_file, delimiter=';', encoding='utf8') |
|
|
import numpy as np |
|
|
|
|
|
|
|
|
dfnumeric=df.select_dtypes(include=np.number) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def write_excel(data,date): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import xlwt |
|
|
import xlrd |
|
|
from xlutils.copy import copy |
|
|
|
|
|
|
|
|
rb = xlrd.open_workbook('07-253-b Estudio capacidad (con grafico).xls', formatting_info=True) |
|
|
|
|
|
|
|
|
wb = copy(rb) |
|
|
|
|
|
|
|
|
w_sheet = wb.get_sheet(1) |
|
|
|
|
|
|
|
|
|
|
|
length=len(data) |
|
|
for i in range(len(date)): |
|
|
|
|
|
|
|
|
w_sheet.write(9+i,0,str(date[i])) |
|
|
w_sheet.write(9+i,1,str(data[i])) |
|
|
|
|
|
|
|
|
|
|
|
data=wb.save('07-253-b Estudio capacidad (con grafico)2.xls') |
|
|
|
|
|
|
|
|
import base64 |
|
|
writer = pd.ExcelWriter('07-253-b Estudio capacidad (con grafico).xls') |
|
|
df.to_excel(writer, index = False, header=True,encoding='utf-8') |
|
|
with open(writer,'rb') as f: |
|
|
b64 = base64.b64encode(f.read()) |
|
|
href = f'<a href="data:file/xls;base64,{b64}" download="new_file.xls">Download xls</a>' |
|
|
|
|
|
st.write(href, unsafe_allow_html=True) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def KYBConvert(df,make_choice): |
|
|
|
|
|
|
|
|
df.to_excel('export.xlsx',index=False) |
|
|
|
|
|
date=pd.to_datetime(df.iloc[:,1], format="%y%m%d-%H:%M") |
|
|
|
|
|
data=pd.Series(df.loc[:,make_choice],dtype="int") |
|
|
|
|
|
write_excel(data,date) |
|
|
|
|
|
|
|
|
|
|
|
if uploaded_file: |
|
|
st.dataframe(dfnumeric) |
|
|
makes = df.select_dtypes([np.number]).columns |
|
|
make_choice = st.sidebar.selectbox('Select cathegory:', makes) |
|
|
print(make_choice) |
|
|
if make_choice!='ID': |
|
|
KYBConvert(df,make_choice) |
|
|
st.write("Puedes encontrar tu excel en: C:/Users/15572890/Desktop/I+D/ProyectosPython/KYB/07-253-b Estudio capacidad (con grafico).xls") |
|
|
|
|
|
|