awacke1 commited on
Commit
b3c643c
ยท
verified ยท
1 Parent(s): 24eca53

Create backup1.app.py

Browse files
Files changed (1) hide show
  1. backup1.app.py +52 -0
backup1.app.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import os
3
+ import xml.etree.ElementTree as ET
4
+
5
+ # Function to create search URL on Wikipedia
6
+ def create_search_url_wikipedia(search_query):
7
+ base_url = "https://www.wikipedia.org/search-redirect.php?family=wikipedia&language=en&search="
8
+ return base_url + search_query.replace(' ', '+').replace('โ€“', '%E2%80%93').replace('&', 'and')
9
+
10
+ # Function to scan for XML files and generate Wikipedia links for organizations
11
+ def scan_for_xml_files_and_generate_links():
12
+ xml_files = [f for f in os.listdir('.') if f.endswith('.xml')]
13
+ for xml_file in xml_files:
14
+ tree = ET.parse(xml_file)
15
+ root = tree.getroot()
16
+ # Assuming the XML structure provided is consistent across files
17
+ for org in root.findall(".//nc:Organization", namespaces={'nc': 'http://niem.gov/niem/niem-core/2.0'}):
18
+ short_name = org.find("nc:OrganizationAbbreviationText", namespaces={'nc': 'http://niem.gov/niem/niem-core/2.0'}).text
19
+ long_name = org.find("nc:OrganizationName", namespaces={'nc': 'http://niem.gov/niem/niem-core/2.0'}).text
20
+ st.markdown(f"- **{short_name}**: [Wikipedia]({create_search_url_wikipedia(short_name)})")
21
+ st.markdown(f"- **{long_name}**: [Wikipedia]({create_search_url_wikipedia(long_name)})")
22
+
23
+ # Streamlit UI
24
+ def app():
25
+ st.title("Freedom of Information Act (FOIA) Open Data ๐ŸŒ๐Ÿ“Š")
26
+ st.write("""
27
+ The Freedom of Information Act (FOIA) empowers individuals by granting access to previously unreleased information and documents controlled by the United States government. Championing transparency and accountability, FOIA serves as a foundation for democratic engagement and open government initiatives. ๐ŸŽ‰โœจ
28
+ Below is a list of datasets available under FOIA, alongside guessed Wikipedia URLs for more information. ๐Ÿ“š๐Ÿ”
29
+ """)
30
+
31
+ # Example datasets under FOIA
32
+ datasets = [
33
+ "Provider Taxonomy",
34
+ "Consumer Complaint Database",
35
+ "Medicare Provider Utilization and Payment Data",
36
+ "Global Terrorism Database",
37
+ "National Nutrient Database",
38
+ "Patent Grant Full Text Data",
39
+ "Toxic Release Inventory",
40
+ "Residential Energy Consumption Survey",
41
+ ]
42
+
43
+ # Displaying the datasets table
44
+ st.markdown("### FOIA Datasets and Wikipedia URLs")
45
+ for dataset in datasets:
46
+ st.markdown(f"- **{dataset}**: [Wikipedia]({create_search_url_wikipedia(dataset)})")
47
+
48
+ st.markdown("### Organizations in Found XML Files")
49
+ scan_for_xml_files_and_generate_links()
50
+
51
+ if __name__ == "__main__":
52
+ app()