Commit
·
c87eab0
1
Parent(s):
16705b8
Upload 2 files
Browse files- app.py +60 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#Run with my server
|
2 |
+
#http://74.208.182.248:8501
|
3 |
+
#python3 -m streamlit.cli run agaconverter/converter02.py
|
4 |
+
|
5 |
+
#Deplo on internet Hugging face
|
6 |
+
#https://towardsdatascience.com/3-easy-ways-to-deploy-your-streamlit-web-app-online-7c88bb1024b1
|
7 |
+
|
8 |
+
import streamlit as st
|
9 |
+
import pandas as pd
|
10 |
+
|
11 |
+
#@st.experimental_memo
|
12 |
+
#def convert_df(df):
|
13 |
+
# return df.to_csv(index=False).encode('utf-8')
|
14 |
+
def forma(entra,decimales,espacios):
|
15 |
+
if decimales==0:
|
16 |
+
a_int=int(entra)
|
17 |
+
a_cadena=str(a_int)
|
18 |
+
a_espacios=a_cadena.rjust(espacios," ")
|
19 |
+
else:
|
20 |
+
a_decimal=float(entra)
|
21 |
+
a_cadena=str(round(a_decimal,decimales))
|
22 |
+
a_espacios=a_cadena.rjust(espacios," ")
|
23 |
+
return a_espacios
|
24 |
+
|
25 |
+
|
26 |
+
st.title('CSV converter from standard format to Weather Extremes extrange format')
|
27 |
+
|
28 |
+
st.subheader('Drag and drop here the standard CSV')
|
29 |
+
spectra = st.file_uploader("upload file", type={"csv", "txt"})
|
30 |
+
if spectra is not None:
|
31 |
+
df = pd.read_csv(spectra)
|
32 |
+
st.subheader('This is the standard CSV')
|
33 |
+
st.write(df)
|
34 |
+
st.subheader('Weather Extremes.exe extrange CSV format')
|
35 |
+
|
36 |
+
data=df.values.tolist()
|
37 |
+
st.write(data)
|
38 |
+
|
39 |
+
new_format ="DAYTON,OH,,,,,,,,,,\r\n"
|
40 |
+
new_format+="Month,Day,Hour,Drybulb,KT,Horiz_Solar,Direct_Normal,Diffuse,DewPoint,WetBulb,RelHum,WindSpeed\r\n"
|
41 |
+
new_format+=" , , ,C, ,kJ/m2,kJ/m2,kJ/m2,C,C,%,m/sec\r\n"
|
42 |
+
|
43 |
+
for renglon in range(2,len(data)):
|
44 |
+
print(renglon,data[renglon])
|
45 |
+
try:
|
46 |
+
#a.rjust(15," ")
|
47 |
+
#(round(float(data[renglon][3]),1)).rjust(5," ")
|
48 |
+
new_format+=data[renglon][0]+','+data[renglon][1]+','+data[renglon][2]+',' +forma(data[renglon][3],1,5)+','+forma(data[renglon][4],2,6)+','+forma(data[renglon][5],0,4)+','+forma(data[renglon][6],0,4)+','+forma(data[renglon][7],0,4)+','+forma(data[renglon][8],1,5)+','+forma(data[renglon][9],1,5)+','+forma(data[renglon][10],1,5)+','+forma(data[renglon][11],1,5)+','+'\r\n'
|
49 |
+
except:
|
50 |
+
print('error',renglon,data[renglon])
|
51 |
+
|
52 |
+
csv = new_format #convert_df(data)
|
53 |
+
|
54 |
+
st.download_button(
|
55 |
+
"Press to Download",
|
56 |
+
csv,
|
57 |
+
"file.csv",
|
58 |
+
"text/csv",
|
59 |
+
key='download-csv'
|
60 |
+
)
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
streamlit
|
2 |
+
pandas
|