Commit e2a584d5 authored by Christophe Benz's avatar Christophe Benz
Browse files

Allow loading CSV both from local file and URL

parent ee27a2f4
......@@ -9,6 +9,10 @@ import as px
from dash.dependencies import Input, Output
from dotenv import load_dotenv
import app_data
"""Interactive OpenDataFrance dashboard."""
......@@ -44,8 +48,6 @@ def compute_dept_dropdown_options(reg_code=None):
return [{"label": "-- département --", "value": ""}] + dep_list
external_stylesheets = ["^1.0/dist/tailwind.min.css"]
server = flask.Flask(__name__)
import os
import unicodedata
from collections import defaultdict
from operator import itemgetter
......@@ -9,9 +10,6 @@ import pandas as pd
"""Manage data used in dashboard."""
ORGANIZATIONS_CSV = "organizations.csv"
def unaccentize(str_with_accents):
"""Remove accents from the given string.
......@@ -27,10 +25,8 @@ def unaccentize(str_with_accents):
# Get data and prepare global variables.
if not Path(ORGANIZATIONS_CSV).is_file():
raise FileNotFoundError(f"Could not find {ORGANIZATIONS_CSV!r}")
df = pd.read_csv(ORGANIZATIONS_CSV)
organizations_csv = os.getenv("ORGANIZATIONS_CSV")
df = pd.read_csv(organizations_csv)
df.columns = [c.replace("-", "_") for c in df.columns]
df = df.astype({"reg_code": str, "dep_code": str})
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment