Spaces:
Runtime error
Runtime error
File size: 2,993 Bytes
76df5b3 24eca53 76df5b3 24eca53 76df5b3 24eca53 76df5b3 18779cf 24eca53 18779cf 24eca53 18779cf 76df5b3 24eca53 eeabdbd 76df5b3 24eca53 76df5b3 24eca53 76df5b3 24eca53 76df5b3 24eca53 76df5b3 24eca53 76df5b3 24eca53 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
import streamlit as st
import os
import xml.etree.ElementTree as ET
# Function to create search URL on Wikipedia
def create_search_url_wikipedia(search_query):
base_url = "https://www.wikipedia.org/search-redirect.php?family=wikipedia&language=en&search="
return base_url + search_query.replace(' ', '+').replace('β', '%E2%80%93').replace('&', 'and')
# Function to scan for XML files and generate links in a markdown table
def scan_for_xml_files_and_generate_links():
xml_files = [f for f in os.listdir('.') if f.endswith('.xml')]
if not xml_files: # Check if the list is empty
st.markdown("No XML files found in the directory.")
return
# Start of the markdown table
markdown_table = "Filename | Abbreviation | Full Name | Links\n--- | --- | --- | ---\n"
for xml_file in xml_files:
tree = ET.parse(xml_file)
root = tree.getroot()
for org in root.findall(".//nc:Organization", namespaces={'nc': 'http://niem.gov/niem/niem-core/2.0'}):
short_name = org.find("nc:OrganizationAbbreviationText", namespaces={'nc': 'http://niem.gov/niem/niem-core/2.0'}).text
long_name = org.find("nc:OrganizationName", namespaces={'nc': 'http://niem.gov/niem/niem-core/2.0'}).text
links = f"[Abbreviation Wikipedia]({create_search_url_wikipedia(short_name)}) | [Full Name Wikipedia]({create_search_url_wikipedia(long_name)})"
markdown_table += f"{xml_file} | {short_name} | {long_name} | {links}\n"
# Display the markdown table
st.markdown(markdown_table)
# Streamlit UI
def app():
st.title("Freedom of Information Act (FOIA) Open Data ππ")
st.write("""
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. πβ¨
Below is a list of datasets available under FOIA, alongside guessed Wikipedia URLs for more information. ππ
# (FOIA.Gov)[https://www.foia.gov/foia-dataset-download.html]
# (Data.Gov)[https://catalog.data.gov/dataset?tags=foia]
""")
# Example datasets under FOIA
datasets = [
"Provider Taxonomy",
"Consumer Complaint Database",
"Medicare Provider Utilization and Payment Data",
"Global Terrorism Database",
"National Nutrient Database",
"Patent Grant Full Text Data",
"Toxic Release Inventory",
"Residential Energy Consumption Survey",
]
# Displaying the datasets table
st.markdown("### FOIA Datasets and Wikipedia URLs")
for dataset in datasets:
st.markdown(f"- **{dataset}**: [Wikipedia]({create_search_url_wikipedia(dataset)})")
st.markdown("### Organizations in Found XML Files")
scan_for_xml_files_and_generate_links()
if __name__ == "__main__":
app()
|