vonshed commited on
Commit
a334148
1 Parent(s): f684965

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -0
app.py CHANGED
@@ -13,6 +13,47 @@ load_dotenv()
13
 
14
 
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
 
18
  # initialize the client
 
13
 
14
 
15
 
16
+ # read csv from user
17
+ def read_csv_file(file):
18
+ """Reads the contents of a CSV file."""
19
+ if not file:
20
+ return None
21
+ data = []
22
+ try:
23
+ with file.streamlit_file_uploader("Choose a CSV file", type="csv") as uploaded_file:
24
+ for row in uploaded_file.getvalue().decode("utf-8").splitlines():
25
+ data.append(row.split(","))
26
+ except Exception as e:
27
+ st.error(f"Error reading CSV file: {e}")
28
+ return None
29
+ return data
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+ data = read_csv_file(st.sidebar.file_uploader("Upload a CSV file"))
39
+
40
+ # Display the data if a file is uploaded
41
+ if data:
42
+ st.subheader("Data from uploaded CSV:")
43
+ st.dataframe(data)
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
 
58
 
59
  # initialize the client