Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -51,31 +51,31 @@ def main():
|
|
| 51 |
selected_files = book_files[selected_book]
|
| 52 |
selected_file = st.sidebar.selectbox("Select a File", selected_files)
|
| 53 |
|
| 54 |
-
st.sidebar.subheader("Files in Selected Book")
|
| 55 |
-
for file in selected_files:
|
| 56 |
-
st.sidebar.write(file)
|
| 57 |
-
|
| 58 |
st.sidebar.subheader("Description")
|
| 59 |
-
st.sidebar.write("This is a viewer for the Hadith collections. You can select a book from the dropdown menu on the left, and choose whether you want to view the '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
-
if
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
paginated_df = csv_df.iloc[start_idx:end_idx]
|
| 76 |
-
st.write(paginated_df)
|
| 77 |
-
else:
|
| 78 |
-
st.error("Error loading CSV file")
|
| 79 |
|
| 80 |
if __name__ == "__main__":
|
| 81 |
main()
|
|
|
|
| 51 |
selected_files = book_files[selected_book]
|
| 52 |
selected_file = st.sidebar.selectbox("Select a File", selected_files)
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
st.sidebar.subheader("Description")
|
| 55 |
+
st.sidebar.write("This is a viewer for the Hadith collections. You can select a book from the dropdown menu on the left, and choose whether you want to view the 'Detailler' version or not.")
|
| 56 |
+
|
| 57 |
+
# Display image on HOME click
|
| 58 |
+
if st.sidebar.button("HOME"):
|
| 59 |
+
st.image("https://raw.githubusercontent.com/halimbahae/Hadith/main/Hadith_Books.jpg", caption="Hadith Books", use_column_width=True)
|
| 60 |
+
|
| 61 |
+
# Load CSV file immediately when selected from the list
|
| 62 |
+
file_url = f"https://raw.githubusercontent.com/halimbahae/Hadith/main/{selected_book}/{selected_file}"
|
| 63 |
+
csv_df = pd.read_csv(file_url, header=None) # Assuming no header in CSV files
|
| 64 |
|
| 65 |
+
if csv_df is not None:
|
| 66 |
+
# Display dataframe with search, filters, and pagination
|
| 67 |
+
st.dataframe(csv_df)
|
| 68 |
+
# Show rows per page selector
|
| 69 |
+
rows_per_page = st.number_input("Rows per Page", min_value=1, value=10)
|
| 70 |
+
# Show page number selector
|
| 71 |
+
page_number = st.number_input("Page Number", min_value=1, value=1)
|
| 72 |
+
# Slice dataframe based on page number and rows per page
|
| 73 |
+
start_idx = (page_number - 1) * rows_per_page
|
| 74 |
+
end_idx = start_idx + rows_per_page
|
| 75 |
+
paginated_df = csv_df.iloc[start_idx:end_idx]
|
| 76 |
+
st.write(paginated_df)
|
| 77 |
+
else:
|
| 78 |
+
st.error("Error loading CSV file")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
if __name__ == "__main__":
|
| 81 |
main()
|