Spaces:
Sleeping
Sleeping
Commit
·
1ba4bc9
1
Parent(s):
7a96f21
deploy
Browse files
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 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
| 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
|