Chittrarasu commited on
Commit
1ba4bc9
·
1 Parent(s): 7a96f21
Files changed (1) hide show
  1. app.py +14 -11
app.py CHANGED
@@ -41,17 +41,20 @@ st.write("Upload a CSV or Excel file containing text data for sentiment analysis
41
  uploaded_file = st.file_uploader("Upload a CSV or Excel file", type=["csv", "xlsx"])
42
 
43
  if uploaded_file is not None:
44
- # Read file
45
- if uploaded_file.name.endswith(".csv"):
46
- df = pd.read_csv(uploaded_file)
47
- else:
48
- df = pd.read_excel(uploaded_file)
49
-
50
- st.write("Dataset Preview:")
51
- st.dataframe(df.head())
52
-
53
- # Select text column
54
- text_column = st.selectbox("Select the text column for analysis", df.columns)
 
 
 
55
 
56
  if st.button("Analyze Sentiment"):
57
  # Get text data
 
41
  uploaded_file = st.file_uploader("Upload a CSV or Excel file", type=["csv", "xlsx"])
42
 
43
  if uploaded_file is not None:
44
+ try:
45
+ # Read file
46
+ if uploaded_file.name.endswith(".csv"):
47
+ df = pd.read_csv(uploaded_file)
48
+ else:
49
+ df = pd.read_excel(uploaded_file)
50
+
51
+ st.write("Dataset Preview:")
52
+ st.dataframe(df.head())
53
+
54
+ # Select text column
55
+ text_column = st.selectbox("Select the text column for analysis", df.columns)
56
+ except Exception as e:
57
+ st.error(f"Error reading file: {e}")
58
 
59
  if st.button("Analyze Sentiment"):
60
  # Get text data