mirror of
https://github.com/koodiklinikka/palkkakysely.git
synced 2026-01-26 03:14:03 +00:00
Add full generation pipeline
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,2 @@
|
|||||||
*.py[cod]
|
*.py[cod]
|
||||||
*.html
|
|
||||||
out
|
out
|
||||||
|
|||||||
9
Makefile
9
Makefile
@@ -1,6 +1,13 @@
|
|||||||
.PHONY: data/results.xlsx data/results.tsv
|
.PHONY: data/results.xlsx data/results.tsv
|
||||||
|
|
||||||
all: data/results.xlsx data/results.tsv
|
out: all-data
|
||||||
|
python massage_templates.py
|
||||||
|
python copy_massaged_data.py
|
||||||
|
python generate_charts.py
|
||||||
|
cp data/results.xlsx out/raw.xlsx
|
||||||
|
cp data/results.tsv out/raw.tsv
|
||||||
|
|
||||||
|
all-data: data/results.xlsx data/results.tsv
|
||||||
|
|
||||||
data/results.xlsx:
|
data/results.xlsx:
|
||||||
curl -fsSL -o $@ "https://docs.google.com/spreadsheets/d/1l-Zgf1HqaFGd8gRA8kQzaxJ3R7eJy29ORUS8pr5o0nk/export?format=xlsx"
|
curl -fsSL -o $@ "https://docs.google.com/spreadsheets/d/1l-Zgf1HqaFGd8gRA8kQzaxJ3R7eJy29ORUS8pr5o0nk/export?format=xlsx"
|
||||||
|
|||||||
12
copy_massaged_data.py
Normal file
12
copy_massaged_data.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
from data_ingest import read_data
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
df = read_data()
|
||||||
|
df.to_html("out/data.html")
|
||||||
|
df.to_csv("out/data.csv")
|
||||||
|
df.to_excel("out/data.xlsx")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
26
massage_templates.py
Normal file
26
massage_templates.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import datetime
|
||||||
|
import glob
|
||||||
|
import os
|
||||||
|
|
||||||
|
import jinja2
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
env = jinja2.Environment(
|
||||||
|
autoescape=True,
|
||||||
|
)
|
||||||
|
data = {
|
||||||
|
"date": datetime.datetime.utcnow(),
|
||||||
|
}
|
||||||
|
for filename in glob.glob("template/*"):
|
||||||
|
out_filename = os.path.join("out", os.path.relpath(filename, "template"))
|
||||||
|
with open(filename, "r") as inf:
|
||||||
|
tpl: jinja2.Template = env.from_string(inf.read())
|
||||||
|
content = tpl.render(data)
|
||||||
|
with open(out_filename, "w") as outf:
|
||||||
|
outf.write(content)
|
||||||
|
print(filename, "=>", out_filename)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
bokeh
|
bokeh
|
||||||
|
jinja2
|
||||||
openpyxl
|
openpyxl
|
||||||
pandas
|
pandas
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ et-xmlfile==1.0.1
|
|||||||
jdcal==1.4.1
|
jdcal==1.4.1
|
||||||
# via openpyxl
|
# via openpyxl
|
||||||
jinja2==2.11.3
|
jinja2==2.11.3
|
||||||
# via bokeh
|
# via
|
||||||
|
# -r requirements.in
|
||||||
|
# bokeh
|
||||||
markupsafe==1.1.1
|
markupsafe==1.1.1
|
||||||
# via jinja2
|
# via jinja2
|
||||||
numpy==1.20.1
|
numpy==1.20.1
|
||||||
|
|||||||
25
template/index.html
Normal file
25
template/index.html
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport"
|
||||||
|
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||||
|
<link rel="stylesheet" href="style.css">
|
||||||
|
<title>Koodiklinikan palkkakysely</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Koodiklinikan palkkakysely</h1>
|
||||||
|
<ul>
|
||||||
|
<li><a href="charts.html">Kaaviot</a></li>
|
||||||
|
<li><a href="data.html">Lähdedata (HTML)</a></li>
|
||||||
|
<li><a href="data.csv">Lähdedata (CSV)</a></li>
|
||||||
|
<li><a href="data.xlsx">Lähdedata (XLSX)</a></li>
|
||||||
|
<li><a href="raw.tsv">Raakadata (TSV)</a></li>
|
||||||
|
<li><a href="raw.xlsx">Raakadata (XLSX)</a></li>
|
||||||
|
</ul>
|
||||||
|
<footer>
|
||||||
|
Generoitu {{ date }}
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
25
template/style.css
Normal file
25
template/style.css
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
body {
|
||||||
|
max-width: 650px;
|
||||||
|
margin: 40px auto;
|
||||||
|
padding: 0 10px;
|
||||||
|
font: 18px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2, h3 {
|
||||||
|
line-height: 1.2
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
body {
|
||||||
|
color: white;
|
||||||
|
background: #444
|
||||||
|
}
|
||||||
|
|
||||||
|
a:link {
|
||||||
|
color: #5bf
|
||||||
|
}
|
||||||
|
|
||||||
|
a:visited {
|
||||||
|
color: #ccf
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user