awacke1 commited on
Commit
cbc4d80
ยท
1 Parent(s): 4462810

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -2
app.py CHANGED
@@ -12,6 +12,33 @@ from st_aggrid import GridUpdateMode, DataReturnMode
12
  # Page config is set once with icon title and display style. Wide mode since we want screen real estate for wide CSV files
13
  st.set_page_config(page_icon="๐Ÿ“", page_title="๐Ÿ“Double Line AI Editor๐Ÿ“Š", layout="wide")
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  # Style
16
  def _max_width_():
17
  max_width_str = f"max-width: 1800px;"
@@ -42,7 +69,8 @@ with c30:
42
  if uploaded_file is not None:
43
  file_container = st.expander("Check your uploaded .csv")
44
  #try:
45
- shows = pd.read_csv(uploaded_file)
 
46
  #except:
47
  # print(sys.exc_info()[2])
48
 
@@ -53,7 +81,13 @@ with c30:
53
  st.stop()
54
 
55
  # DisplayGrid
 
 
 
 
 
56
  gb = GridOptionsBuilder.from_dataframe(shows)
 
57
  gb.configure_default_column(enablePivot=True, enableValue=True, enableRowGroup=True)
58
  gb.configure_selection(selection_mode="multiple", use_checkbox=True)
59
  gb.configure_side_bar()
@@ -80,4 +114,5 @@ c29, c30, c31 = st.columns([1, 1, 2])
80
  with c29:
81
  CSVButton = download_button(df,"Dataset.csv","Download CSV file",)
82
  with c30:
83
- CSVButton = download_button(df,"Dataset.txt","Download TXT file",)
 
 
12
  # Page config is set once with icon title and display style. Wide mode since we want screen real estate for wide CSV files
13
  st.set_page_config(page_icon="๐Ÿ“", page_title="๐Ÿ“Double Line AI Editor๐Ÿ“Š", layout="wide")
14
 
15
+ def parse(file, condition, data=[], ind_append=False):
16
+ for line in file:
17
+ st.write(line)
18
+ data.append(line)
19
+ return data
20
+
21
+ def read_csv_any_file(file):
22
+ dropBlanks=True
23
+ logResult=True
24
+ logResultStartSymbol = "["
25
+
26
+
27
+ if file is not None:
28
+ data = []
29
+ df = pd.DataFrame()
30
+ for line in file:
31
+ if line == b' \r\n':
32
+ if dropBlanks == False:
33
+ st.write(line.decode('UTF-8'))
34
+ else:
35
+ if logResult:
36
+ st.write(line.decode('UTF-8'))
37
+ data.append(line.decode('UTF-8'))
38
+
39
+ df = pd.DataFrame(data, columns=['InputLines'])
40
+ return df
41
+
42
  # Style
43
  def _max_width_():
44
  max_width_str = f"max-width: 1800px;"
 
69
  if uploaded_file is not None:
70
  file_container = st.expander("Check your uploaded .csv")
71
  #try:
72
+ shows = read_csv_any_file(uploaded_file)
73
+ #shows = pd.read_csv(uploaded_file)
74
  #except:
75
  # print(sys.exc_info()[2])
76
 
 
81
  st.stop()
82
 
83
  # DisplayGrid
84
+ #gb = GridOptionsBuilder.from_dataframe(shows)
85
+
86
+ #z = [[" ".join(i.split()[:2]),str(i.split()[2])] for i in shows]
87
+ #df = pd.DataFrame(z,columns=['Str','Str2'])
88
+
89
  gb = GridOptionsBuilder.from_dataframe(shows)
90
+
91
  gb.configure_default_column(enablePivot=True, enableValue=True, enableRowGroup=True)
92
  gb.configure_selection(selection_mode="multiple", use_checkbox=True)
93
  gb.configure_side_bar()
 
114
  with c29:
115
  CSVButton = download_button(df,"Dataset.csv","Download CSV file",)
116
  with c30:
117
+ CSVButton = download_button(df,"Dataset.txt","Download TXT file",)
118
+