forked from lmmentel/mendeleev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.py
45 lines (40 loc) · 1.02 KB
/
tasks.py
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
from pathlib import Path
from invoke import task
@task
def export(c):
"""Export data to a few formats files."""
tables = [
"elements",
"groups",
"ionicradii",
"ionizationenergies",
"isotopedecaymodes",
"isotopes",
"oxidationstates",
"phasetransitions",
"screeningconstants",
"series",
]
formats = [
"csv",
"html",
"json",
"markdown",
]
for fmt in formats:
Path(f"data/{fmt}").mkdir(exist_ok=True)
for table in tables:
print(f"Exporting {table} to {fmt} ... ", end="")
c.run(
f"sqlite3 -{fmt} mendeleev/elements.db 'SELECT * FROM {table};' > data/{fmt}/{table}.{fmt}",
echo=True,
)
print("done")
# SQL dump
print("Creating SQL files with the data ... ", end="")
c.run(
"sqlite3 mendeleev/elements.db .dump > data/sql/elements.sql",
echo=True,
pty=True,
)
print("done")