Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -144,15 +144,15 @@ if upload_file is not None:
|
|
144 |
file_extension = upload_file.name.split('.')[-1].lower()
|
145 |
if file_extension == 'csv':
|
146 |
try:
|
147 |
-
|
148 |
-
if
|
149 |
st.error("Error: The CSV file contains missing values.")
|
150 |
st.stop()
|
151 |
else:
|
152 |
-
st.dataframe(
|
153 |
-
st.write("_number of rows_",
|
154 |
-
st.write("_number of columns_",
|
155 |
-
st.session_state.
|
156 |
except pd.errors.ParserError:
|
157 |
st.error("Error: The CSV file is not readable or is incorrectly formatted.")
|
158 |
st.stop()
|
@@ -199,9 +199,9 @@ if st.button("Retrieve your answer"):
|
|
199 |
|
200 |
with st.spinner("Wait for it...", show_time=True):
|
201 |
time.sleep(5)
|
202 |
-
if
|
203 |
tqa = pipeline(task="table-question-answering", model="microsoft/tapex-large-finetuned-wtq")
|
204 |
-
st.write(tqa(table=
|
205 |
|
206 |
st.divider()
|
207 |
st.write(f"Number of questions asked: {st.session_state['question_attempts']}/{max_attempts}")
|
|
|
144 |
file_extension = upload_file.name.split('.')[-1].lower()
|
145 |
if file_extension == 'csv':
|
146 |
try:
|
147 |
+
df1 = pd.read_csv(upload_file, na_filter=False)
|
148 |
+
if df1.isnull().values.any():
|
149 |
st.error("Error: The CSV file contains missing values.")
|
150 |
st.stop()
|
151 |
else:
|
152 |
+
st.dataframe(df1, key="csv_dataframe")
|
153 |
+
st.write("_number of rows_", df1.shape[0])
|
154 |
+
st.write("_number of columns_", df1.shape[1])
|
155 |
+
st.session_state.df1 = df1
|
156 |
except pd.errors.ParserError:
|
157 |
st.error("Error: The CSV file is not readable or is incorrectly formatted.")
|
158 |
st.stop()
|
|
|
199 |
|
200 |
with st.spinner("Wait for it...", show_time=True):
|
201 |
time.sleep(5)
|
202 |
+
if df1 is not None:
|
203 |
tqa = pipeline(task="table-question-answering", model="microsoft/tapex-large-finetuned-wtq")
|
204 |
+
st.write(tqa(table=df1, query=question)['answer'])
|
205 |
|
206 |
st.divider()
|
207 |
st.write(f"Number of questions asked: {st.session_state['question_attempts']}/{max_attempts}")
|