From cd86dd330fa8175153ccb707b25287a8fb6322f9 Mon Sep 17 00:00:00 2001 From: Marek Sedlacek Date: Mon, 19 Feb 2024 13:33:11 +0100 Subject: [PATCH 1/2] Pridani dedikovane tabulky s cinnostmi dle ICO --- data/ares/main.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/data/ares/main.py b/data/ares/main.py index a654173..8d610cf 100644 --- a/data/ares/main.py +++ b/data/ares/main.py @@ -87,10 +87,12 @@ def remote_data(partial): def main(outdir: str, partial: bool = False): with open(os.path.join(outdir, "firmy.csv"), "w", encoding="utf8") as ud, open( os.path.join(outdir, "fosoby.csv"), "w", encoding="utf8" - ) as fo, open(os.path.join(outdir, "posoby.csv"), "w", encoding="utf8") as po: + ) as fo, open(os.path.join(outdir, "posoby.csv"), "w", encoding="utf8" + ) as po, open(os.path.join(outdir,"cinnosti.csv"),"w",encoding="utf-8") as co: udc = csv.writer(ud, lineterminator="\n") foc = csv.writer(fo, lineterminator="\n") poc = csv.writer(po, lineterminator="\n") + coc = csv.writer(co,lineterminator="\n") cols = [ "zdroj", @@ -134,6 +136,14 @@ def main(outdir: str, partial: bool = False): ] ) + coc.writerow( + [ + "ico", + "typ_cinnosti", + "text", + ] + ) + for rw, (el, fl) in enumerate(remote_data(partial)): et = lxml.etree.fromstring(fl) @@ -203,6 +213,12 @@ def main(outdir: str, partial: bool = False): for j in org["posoby"]: poc.writerow(j) + for txt in vypis.iterfind( + ".//are:Cinnosti/*/are:Text", namespaces=et.nsmap + ): + text = txt.text.strip() + ctype = txt.getparent().tag.rpartition("}")[-1] + coc.writerow([ico, ctype, text]) if __name__ == "__main__": main(".") From 65209467875d06a58def462c225bc5e6b5b9fa7f Mon Sep 17 00:00:00 2001 From: Marek Sedlacek Date: Mon, 19 Feb 2024 13:37:09 +0100 Subject: [PATCH 2/2] Pridani tabulky cinnosti do schema ares --- data/ares/schema.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/data/ares/schema.py b/data/ares/schema.py index 12cffdc..b4f9ff0 100644 --- a/data/ares/schema.py +++ b/data/ares/schema.py @@ -46,6 +46,13 @@ Column("ico_organ", Integer, nullable=True, index=True), Column("adresa", JSON, nullable=True), ), + Table( + "cinnosti", + meta, + Column("ico", Integer, nullable=False, index=True), + Column("typ_cinnost", Text, nullable=True), + Column("text", Text, nullable=True), + ) ]