awacke1 commited on
Commit
49f4355
·
verified ·
1 Parent(s): f0de933

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +123 -1
app.py CHANGED
@@ -11,6 +11,9 @@
11
  #tmp_dataset = tmp_dataset.add_item(new_item), but i can’t figure out how to do this while my dataset is streaming=True.
12
  #Can anyone help me to find solution, please?
13
 
 
 
 
14
 
15
  if st.checkbox('Show Anatomy Table'):
16
  st.markdown("""
@@ -41,7 +44,126 @@ if st.checkbox('Show Anatomy Table'):
41
 
42
  """)
43
 
44
- import streamlit as st
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  import pandas as pd
46
 
47
  # Load dataset
 
11
  #tmp_dataset = tmp_dataset.add_item(new_item), but i can’t figure out how to do this while my dataset is streaming=True.
12
  #Can anyone help me to find solution, please?
13
 
14
+ import streamlit as st
15
+
16
+ st.set_page_config(page_icon="📝", page_title="📝AI-EIO-Editor📊", layout="wide")
17
 
18
  if st.checkbox('Show Anatomy Table'):
19
  st.markdown("""
 
44
 
45
  """)
46
 
47
+
48
+ import streamlit as st
49
+ import pandas as pd
50
+ import traceback
51
+ import sys
52
+
53
+ from st_aggrid import AgGrid
54
+ from st_aggrid.grid_options_builder import GridOptionsBuilder
55
+ from st_aggrid.shared import JsCode
56
+ from download import download_button
57
+ from st_aggrid import GridUpdateMode, DataReturnMode
58
+
59
+ def parse(file, condition, data=[], ind_append=False):
60
+ for line in file:
61
+ st.write(line)
62
+ data.append(line)
63
+ return data
64
+
65
+ def read_csv_any_file(file):
66
+ dropBlanks=True
67
+ logResult=True
68
+ logResultStartSymbol = "["
69
+
70
+
71
+ if file is not None:
72
+ data = []
73
+ df = pd.DataFrame()
74
+ for line in file:
75
+ if line == b' \r\n':
76
+ if dropBlanks == False:
77
+ st.write(line.decode('UTF-8'))
78
+ else:
79
+ if logResult:
80
+ st.write(line.decode('UTF-8'))
81
+ data.append(line.decode('UTF-8'))
82
+
83
+ df = pd.DataFrame(data, columns=['InputLines'])
84
+ return df
85
+
86
+ # Style
87
+ def _max_width_():
88
+ max_width_str = f"max-width: 1800px;"
89
+ st.markdown(
90
+ f"""
91
+ <style>
92
+ .reportview-container .main .block-container{{
93
+ {max_width_str}
94
+ }}
95
+ </style>
96
+ """,
97
+ unsafe_allow_html=True,
98
+ )
99
+
100
+ # Title Bar with Images and Icons
101
+ col1, col2, col3 = st.columns([1,6,1])
102
+ with col1:
103
+ st.image("https://cdnb.artstation.com/p/assets/images/images/054/910/875/large/aaron-wacker-cyberpunk-computer-brain-design.jpg?1665656558",width=64,)
104
+ with col2:
105
+ st.title("📝Double Line AI Editor📊")
106
+ with col3:
107
+ st.image("https://cdna.artstation.com/p/assets/images/images/054/910/878/large/aaron-wacker-cyberpunk-computer-devices-iot.jpg?1665656564",width=64,)
108
+
109
+ # Upload
110
+ c29, c30, c31 = st.columns([1, 6, 1])
111
+ with c30:
112
+ uploaded_file = st.file_uploader("", key="1", help="To activate 'wide mode', go to the menu > Settings > turn on 'wide mode'",)
113
+ if uploaded_file is not None:
114
+ file_container = st.expander("Check your uploaded .csv")
115
+ #try:
116
+ shows = read_csv_any_file(uploaded_file)
117
+ #shows = pd.read_csv(uploaded_file)
118
+ #except:
119
+ # print(sys.exc_info()[2])
120
+
121
+ uploaded_file.seek(0)
122
+ file_container.write(shows)
123
+ else:
124
+ st.info(f"""⬆️Upload a 📝.CSV file. Examples: [Chatbot](https://huggingface.co/datasets/awacke1/Carddata.csv) [Mindfulness](https://huggingface.co/datasets/awacke1/MindfulStory.csv) [Wikipedia](https://huggingface.co/datasets/awacke1/WikipediaSearch)""")
125
+ st.stop()
126
+
127
+ # DisplayGrid
128
+ #gb = GridOptionsBuilder.from_dataframe(shows)
129
+
130
+ #z = [[" ".join(i.split()[:2]),str(i.split()[2])] for i in shows]
131
+ #df = pd.DataFrame(z,columns=['Str','Str2'])
132
+
133
+ gb = GridOptionsBuilder.from_dataframe(shows)
134
+
135
+ gb.configure_default_column(enablePivot=True, enableValue=True, enableRowGroup=True)
136
+ gb.configure_selection(selection_mode="multiple", use_checkbox=True)
137
+ gb.configure_side_bar()
138
+ gridOptions = gb.build()
139
+ st.success(f"""💡 Tip! Hold shift key when selecting rows to select multiple rows at once.""")
140
+ response = AgGrid(
141
+ shows,
142
+ gridOptions=gridOptions,
143
+ enable_enterprise_modules=True,
144
+ update_mode=GridUpdateMode.MODEL_CHANGED,
145
+ data_return_mode=DataReturnMode.FILTERED_AND_SORTED,
146
+ fit_columns_on_grid_load=False,
147
+ )
148
+
149
+ # Filters
150
+ df = pd.DataFrame(response["selected_rows"])
151
+ st.subheader("Filtered data will appear below 📊 ")
152
+ st.text("")
153
+ st.table(df)
154
+ st.text("")
155
+
156
+ # Download
157
+ c29, c30, c31 = st.columns([1, 1, 2])
158
+ with c29:
159
+ CSVButton = download_button(df,"Dataset.csv","Download CSV file",)
160
+ with c30:
161
+ CSVButton = download_button(df,"Dataset.txt","Download TXT file",)
162
+
163
+
164
+ #-----------------------------------------------------------------------
165
+
166
+ import streamlit as st
167
  import pandas as pd
168
 
169
  # Load dataset