Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Christophe Benz
observatoire-dash
Commits
e2a584d5
Commit
e2a584d5
authored
Jan 13, 2020
by
Christophe Benz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow loading CSV both from local file and URL
parent
ee27a2f4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
9 deletions
+8
-9
.env.example
.env.example
+1
-0
app.py
app.py
+4
-2
app_data.py
app_data.py
+3
-7
No files found.
.env.example
View file @
e2a584d5
MAPBOX_TOKEN=
ORGANIZATIONS_CSV=organizations.csv
app.py
View file @
e2a584d5
...
...
@@ -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__
)
...
...
app_data.py
View file @
e2a584d5
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
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment