Commit e2a584d5 authored by Christophe Benz's avatar Christophe Benz

Allow loading CSV both from local file and URL

parent ee27a2f4
MAPBOX_TOKEN=
ORGANIZATIONS_CSV=organizations.csv
......@@ -9,6 +9,10 @@ import plotly.express as px
from dash.dependencies import Input, Output
from dotenv import load_dotenv
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
load_dotenv()
external_stylesheets = ["https://unpkg.com/tailwindcss@^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})
......
Markdown is supported
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