Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[misc] rejstrik trestu PO #189

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions data/misc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Misc

Náhodné další datasety, které jsou a) malé, b) jednotabulkové

- [Rejstřík trestů právnických osob](https://eservice-po.rejtr.justice.cz/public/odsouzeni;jsessionid=E925E6A2467577AB9730F7F9BA96D3E9.pocluster1?0)
19 changes: 19 additions & 0 deletions data/misc/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import csv
import io
import os
from urllib.request import urlopen

URL_ODSOUZENE_PO = "https://eservice-po.rejtr.justice.cz/public/odsouzeni_csv"


def main(outdir: str, partial: bool = False):
with urlopen(URL_ODSOUZENE_PO) as r, open(
os.path.join(outdir, "odsouzene_po.csv"), "w", encoding="utf-8"
) as fw:
cw = csv.writer(fw, lineterminator="\n")
for row in csv.reader(io.TextIOWrapper(r, encoding="utf-8")):
cw.writerow(row)


if __name__ == "__main__":
main(".")
27 changes: 27 additions & 0 deletions data/misc/schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from sqlalchemy import Column, MetaData, Table
from sqlalchemy.sql.sqltypes import Integer, Text

meta = MetaData()


schema = [
Table(
"odsouzene_po",
meta,
Column("ico", Integer, nullable=True, index=True),
Column("obchodni_jmeno", Text, nullable=False),
Column("sidlo", Text, nullable=True),
Column("stat", Text, nullable=False),
Column("odsouzeni", Text, nullable=False),
)
]


if __name__ == "__main__":
from sqlalchemy import create_engine
from sqlalchemy.schema import CreateTable

engine = create_engine("sqlite:///:memory:")
for table in schema:
print(f"-- {table.name} as created in SQLite")
print(CreateTable(table).compile(engine))