Skip to content

Commit a0a0004

Browse files
author
anna.yamkovaya
committed
added main page and pages with uploading
1 parent 17542bb commit a0a0004

File tree

4 files changed

+52
-38
lines changed

4 files changed

+52
-38
lines changed

main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55

66
PAGES = {
7-
"Annotations Upload": upload.annotations,
8-
"Requirements Upload": upload.requirements,
7+
"Annotations Upload": upload.annotations.show,
8+
"Requirements Upload": upload.requirements.show,
99
}
1010

1111

pages/upload/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from pages.upload import annotations
2+
from pages.upload import requirements

pages/upload/annotations.py

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
1+
import io
2+
13
import streamlit as st
24
import csv
35

4-
st.title("Upload *.trace.csv file")
56

6-
uploaded_file = st.file_uploader("Choose a *.trace.csv file", type="csv")
7+
def show():
8+
st.title("Upload *.trace.csv file")
9+
10+
uploaded_files = st.file_uploader("Choose a *.trace.csv file", type="csv", accept_multiple_files=True)
711

8-
if uploaded_file is not None:
9-
try:
10-
# Read the file as a string
11-
with open(uploaded_file, "r") as trace_file:
12-
reader = csv.reader(trace_file)
12+
for uploaded_file in uploaded_files:
13+
try:
14+
# Read the file as a string
15+
stringio = io.StringIO(uploaded_file.getvalue().decode("utf-8"))
16+
reader = csv.reader(stringio)
1317
rows = list(reader)
1418
# run indexing
1519
# run trace
1620

17-
if rows:
18-
st.success("CSV file uploaded and parsed successfully!")
19-
st.subheader("Extracted Rows:")
20-
# Display as a table
21-
st.table(rows)
22-
else:
23-
st.warning("The uploaded CSV file is empty.")
24-
except Exception as e:
25-
st.error(f"Failed to parse CSV file: {e}")
26-
else:
27-
st.info("Please upload a *.trace.csv file to extract rows.")
21+
if rows:
22+
st.success("CSV file uploaded and parsed successfully!")
23+
st.subheader("Extracted Rows:")
24+
# Display as a table
25+
st.table(rows)
26+
else:
27+
st.warning("The uploaded CSV file is empty.")
28+
except Exception as e:
29+
st.error(f"Failed to parse CSV file: {e}")
30+
31+
if not uploaded_files:
32+
st.info("Please upload a *.trace.csv file to extract rows.")
33+
return False

pages/upload/requirements.py

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
1+
import io
2+
13
import streamlit as st
24
import csv
35

4-
st.title("Upload a file with requirements.")
56

6-
uploaded_file = st.file_uploader("Choose a file with requirements", type="csv")
7+
def show():
8+
st.title("Upload a file with requirements.")
9+
10+
uploaded_files = st.file_uploader("Choose a file with requirements", type="csv")
711

8-
if uploaded_file is not None:
9-
try:
10-
# Read the file as a string
11-
with open(uploaded_file, "r") as trace_file:
12-
reader = csv.reader(trace_file)
12+
for uploaded_file in uploaded_files:
13+
try:
14+
15+
stringio = io.StringIO(uploaded_file.getvalue().decode("utf-8"))
16+
reader = csv.reader(stringio)
1317
rows = list(reader)
1418
# run indexing
1519

16-
if rows:
17-
st.success("CSV file uploaded and parsed successfully!")
18-
st.subheader("Extracted Rows:")
19-
# Display as a table
20-
st.table(rows)
21-
else:
22-
st.warning("The uploaded CSV file is empty.")
23-
except Exception as e:
24-
st.error(f"Failed to parse CSV file: {e}")
25-
else:
26-
st.info("Please upload a file with requirements to extract rows.")
20+
if rows:
21+
st.success("CSV file uploaded and parsed successfully!")
22+
st.subheader("Extracted Rows:")
23+
# Display as a table
24+
st.table(rows)
25+
else:
26+
st.warning("The uploaded CSV file is empty.")
27+
except Exception as e:
28+
st.error(f"Failed to parse CSV file: {e}")
29+
30+
if not uploaded_files:
31+
st.info("Please upload a *.trace.csv file to extract rows.")
32+
return False

0 commit comments

Comments
 (0)