halimbahae commited on
Commit
b5c4b4f
·
verified ·
1 Parent(s): b219ee9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -9
app.py CHANGED
@@ -1,6 +1,5 @@
1
  import streamlit as st
2
  import pandas as pd
3
- import requests
4
 
5
  # Define array of file paths for each book
6
  book_files = {
@@ -42,25 +41,19 @@ book_files = {
42
  ]
43
  }
44
 
45
- # Main Streamlit app
46
  def main():
47
- st.title("Hadith Viewer")
48
-
49
  st.sidebar.title("Navigation")
50
  st.sidebar.subheader("Actions")
51
  if st.sidebar.button("Home"):
52
  display_home()
53
-
54
  st.sidebar.title("Books")
55
  selected_book = st.sidebar.selectbox("Select a Book", list(book_files.keys()))
56
-
57
  selected_files = book_files[selected_book]
58
  selected_file = st.sidebar.selectbox("Select a File", selected_files)
59
 
60
  # Load CSV file immediately when selected from the list
61
  file_url = f"https://raw.githubusercontent.com/halimbahae/Hadith/main/{selected_book}/{selected_file}"
62
  csv_df = pd.read_csv(file_url, header=None) # Assuming no header in CSV files
63
-
64
  if csv_df is not None:
65
  # Display dataframe with search
66
  display_table(csv_df)
@@ -75,7 +68,9 @@ def display_table(csv_df):
75
  st.write("### Table View")
76
  search_query = st.sidebar.text_input("Search", "")
77
  filtered_df = csv_df[csv_df.apply(lambda row: row.astype(str).str.contains(search_query, case=False).any(), axis=1)]
78
- st.dataframe(filtered_df.style.set_properties(**{'font-size': f'{font_size}px'}))
 
79
 
80
  if __name__ == "__main__":
81
- main()
 
 
1
  import streamlit as st
2
  import pandas as pd
 
3
 
4
  # Define array of file paths for each book
5
  book_files = {
 
41
  ]
42
  }
43
 
 
44
  def main():
 
 
45
  st.sidebar.title("Navigation")
46
  st.sidebar.subheader("Actions")
47
  if st.sidebar.button("Home"):
48
  display_home()
 
49
  st.sidebar.title("Books")
50
  selected_book = st.sidebar.selectbox("Select a Book", list(book_files.keys()))
 
51
  selected_files = book_files[selected_book]
52
  selected_file = st.sidebar.selectbox("Select a File", selected_files)
53
 
54
  # Load CSV file immediately when selected from the list
55
  file_url = f"https://raw.githubusercontent.com/halimbahae/Hadith/main/{selected_book}/{selected_file}"
56
  csv_df = pd.read_csv(file_url, header=None) # Assuming no header in CSV files
 
57
  if csv_df is not None:
58
  # Display dataframe with search
59
  display_table(csv_df)
 
68
  st.write("### Table View")
69
  search_query = st.sidebar.text_input("Search", "")
70
  filtered_df = csv_df[csv_df.apply(lambda row: row.astype(str).str.contains(search_query, case=False).any(), axis=1)]
71
+ styled_df = filtered_df.style.set_properties(**{'font-size': f'{font_size}px'})
72
+ st.dataframe(styled_df)
73
 
74
  if __name__ == "__main__":
75
+ display_home()
76
+ main()