From fb56915ec06b206f6e4afa2e0e2bdca0eb3df18f Mon Sep 17 00:00:00 2001 From: Ondrej Kokes Date: Tue, 10 Jan 2023 13:13:35 +0000 Subject: [PATCH 1/3] wip --- data/zakazky/main.py | 110 ++++---- data/zakazky/mapping.json | 518 ++++++++++---------------------------- data/zakazky/schema.py | 470 +++++++++++++++++----------------- main.py | 6 +- 4 files changed, 414 insertions(+), 690 deletions(-) diff --git a/data/zakazky/main.py b/data/zakazky/main.py index 87aa083..34bcb42 100644 --- a/data/zakazky/main.py +++ b/data/zakazky/main.py @@ -4,7 +4,9 @@ import csv import datetime as dt import gzip +import io import json +import shutil import os import re import ssl @@ -12,9 +14,8 @@ from datetime import datetime from urllib.request import Request, urlopen -from lxml.etree import iterparse - # ISVZ nema duveryhodny certy +# TODO(PR): overit ssl._create_default_https_context = ssl._create_unverified_context @@ -70,78 +71,53 @@ def read_url(url): root_url = "https://isvz.nipez.cz/sites/default/files/content/opendata-predchozi/" url_sources = { "zzvz": ( - root_url + "ODZZVZ/{}.xml", + root_url + "ODZZVZSS/{year}_{table}.csv", list(range(2016, 2022 + 1)), ), - "vvz": ( - root_url + "ODVVZ/{}.xml", - list(range(2006, 2016 + 1)), - ), - "etrziste": ( - root_url + "ODET/{}.xml", - list(range(2012, 2017 + 1)), - ), + # TODO(PR): tohle je pro nas nove (a naopak vvz/etrziste nemame) + # "zzvzmo": ( + # root_url + "ODZZVZMOSS/{}_{}.csv", + # list(range(2016, 2022 + 1)), + # {"VerejnaZakazka": "vz", "CastiVerejneZakazky": "casti_vz"}, + # ), + # TODO(PR): tohle v datech neni + # "vvz": ( + # root_url + "ODVVZ/{}.xml", + # list(range(2006, 2016 + 1)), + # ), + # "etrziste": ( + # root_url + "ODET/{}.xml", + # list(range(2012, 2017 + 1)), + # ), } def main(outdir: str, partial: bool = False): cdir = os.path.dirname(os.path.abspath(__file__)) - with open(os.path.join(cdir, "mapping.json"), encoding="utf-8") as f: - allmaps = json.load(f) - - assert list(allmaps.keys()) == ["etrziste", "vvz", "zzvz"] - - for ds, mapping in allmaps.items(): - filehandles, csvwriters = {}, {} - - for v in mapping.values(): - full_ds = f"{ds}_{v['table']}" - tfn = os.path.join(outdir, f"{full_ds}.csv") - filehandles[full_ds] = open(tfn, "w", encoding="utf8") - csvwriters[full_ds] = csv.DictWriter( - filehandles[full_ds], - fieldnames=v["header"], - lineterminator="\n", - ) - csvwriters[full_ds].writeheader() - - base_url, years = url_sources[ds] - - for year in years: - if partial and year != years[-1]: - continue - print(ds, year) - url = base_url.format(year) - with read_url(url) as resp: - for action, element in iterparse(resp): - assert action == "end" - if element.tag not in mapping: - continue - mp = mapping[element.tag] - full_ds = f"{ds}_{mp['table']}" - - row = { - el.tag: el.text.strip() if el.text else None - for el in element.getchildren() - } - - for k, v in row.items(): - if k in mp.get("dates", []): - row[k] = fix_date(v) - if v and k in mp.get("numeric", []): - row[k] = v.replace(",", ".") - if "ICO" in k: - ico = fix_ico(v) - if ico is None and v is not None: - print("nevalidni ico", v, f"({full_ds}, {url})") - row[k] = ico - - csvwriters[full_ds].writerow(row) - - element.clear() - - for fh in filehandles.values(): - fh.close() + with open(os.path.join(cdir, "mapping.json")) as f: + mapping = json.load(f) + + for dataset, mp in mapping.items(): + base_url, years = url_sources[dataset] + for table, props in mp.items(): + for year in years: + print(dataset, table, year) + + if partial and year != years[-1]: + continue + tdir = os.path.join(outdir, f"{dataset}_{props['table']}") + os.makedirs(tdir, exist_ok=True) + tfn = os.path.join(tdir, f"{year}.csv") + url = base_url.format(year=year, table=table) + with read_url(url) as resp, open(tfn, "wt", encoding="utf-8") as fw: + r = io.TextIOWrapper(resp, encoding="utf-8") + cr = csv.DictReader(r) + # TODO: nemame garanci poradi klicu (je to impl. detail) - asi lepsi predelat ze slovniku + cw = csv.DictWriter(fw, lineterminator="\n", fieldnames=props["header"].values()) + # cw = csv.writer(fw) + cw.writeheader() + for row in cr: + cw.writerow({v: row[k] for k, v in props["header"].items()}) if __name__ == "__main__": diff --git a/data/zakazky/mapping.json b/data/zakazky/mapping.json index 5bd359a..6fe80e4 100644 --- a/data/zakazky/mapping.json +++ b/data/zakazky/mapping.json @@ -1,404 +1,152 @@ { - "etrziste": { - "CastiVZ": { - "table": "casti_vz", - "header": [ - "VZsystemoveCislo", - "CastVZcislo", - "SmluvniCenaVcetneDPH", - "SmluvniCenaBezDPH", - "SmluvniCenaSazbaDPH", - "SmluvniCenaMena" - ], - "numeric": [ - "SmluvniCenaBezDPH", - "SmluvniCenaVcetneDPH" - ] - }, - "PolozkyVZ": { - "table": "polozky_vz", - "header": [ - "VZsystemoveCislo", - "NIPEZkod", - "NIPEZnazev", - "NIPEZpovinnostProEtrziste", - "NIPEZnazevVlastnosti", - "NIPEZdatovyTypVlastnosti", - "NIPEZhodnotaVlastnosti", - "NIPEZmernaJednotkaVlastnosti", - "NIPEZoperatorVlastnosti" - ], - "numeric": "NIPEZhodnotaVlastnosti" - }, - "Kriteria": { - "table": "kriteria_vz", - "header": [ - "VZsystemoveCislo", - "DilciHodnoticiKriterium", - "DilciHodnoticiKriteriumVaha", - "DilciKriteriumCiselneVyjadritelne", - "DilciKriteriumPredmetemEaukce", - "DilciKriteriumZadavatelPozadovalVlozeniNabidkovychHodnot", - "SubkriteriumNabidkoveCeny", - "SubkriteriumNabidkoveCenyVaha", - "SubkriteriumDilcihoKriteria", - "SubkriteriumDilcihoKriteriaVaha", - "SubkriteriumCiselneVyjadritelne", - "SubkriteriumPredmetemEaukce", - "SubkriteriumZadavatelPozadovalVlozeniNabidkovychHodnot" - ] - }, - "ViceDodavatelu": { - "table": "dodavatele", - "header": [ - "VZsystemoveCislo", - "CastVZcislo", - "DatumUzavreniSmlouvy", - "DodavatelUredniNazev", - "DodavatelICO", - "DodavatelStat" - ] - }, - "Zakazky": { - "table": "vz", - "header": [ - "NazevEtrziste", - "VZsystemoveCislo", - "NazevVZ", - "VZstav", - "VZdruh", - "VZtyp", - "DruhZadavaciRizeni", - "PredpokladanaHodnotaVZ", - "CelkovaSmluvniCenaBezDPH", - "CelkovaSmluvniCenaVcetneDPH", - "CelkovaSmluvniCenaMena", - "ZadavatelNazev", - "ZadavatelICO", - "ZadavatelKategorie", - "VysledekZadavacihoRizeni", - "DatumUzavreniSmlouvy", - "DelenaNaCasti", - "PocetCasti", - "PocetPolozekVZ", - "MetodaHodnoceni", - "ZakladniHodnoticiKriterium", - "ZruseniVZ", - "DatumZruseniZadavacihoRizeni", - "BylaDoZRzarazenaEaukce", - "PocetVyzvanychDodavatelu", - "PocetObdrzenychNabidek", - "PocetHodnocenychNabidek", - "NamitkyPocet", - "NamitkyVyhoveno", - "PrezkumUkonu", - "PrezkumnychRizeniPocet", - "ZadostioDodatecneInformacePocet", - "DodavatelNazev", - "DodavatelICO" - ], - "numeric": [ - "CelkovaSmluvniCenaBezDPH", - "CelkovaSmluvniCenaVcetneDPH", - "PredpokladanaHodnotaVZ" - ], - "dates": [ - "DatumUzavreniSmlouvy", - "DatumZruseniZadavacihoRizeni" - ] - } - }, - "vvz": { - "CastiVerejneZakazky": { - "table": "casti_vz", - "header": [ - "EvidencniCisloVZnaVVZ", - "CisloFormulareNaVVZ", - "CisloCastiZadaniVZ", - "NazevCastiVZ", - "DatumZadaniVZ", - "PocetObdrzenychNabidek", - "DodavatelNazev", - "DodavatelICOZeZadani", - "DodavatelPostovniAdresa", - "DodavatelObec", - "DodavatelPSC", - "DodavatelStat", - "DodavatelWww", - "PuvodniOdhadovanaCelkovaHodnotaVZ", - "PuvodniOdhadovanaCelkovaHodnotaVZMena", - "PuvodniOdhadovanaCelkovaHodnotaVZsazbaDPH", - "PuvodniOdhadovanaCelkovaHodnotaVZprocentniSazbaDPH", - "CelkovaKonecnaHodnotaVZzaZadani", - "CelkovaKonecnaHodnotaVZmenaZaZadani", - "CelkovaKonecnaHodnotaVZSazbaDPHzaZadani", - "CelkovaKonecnaHodnotaVZprocentniSazbaDPHzaZadani", - "HodnotaNejnizsiNabidky", - "HodnotaNejnizsiNabidkyMena", - "HodnotaNejnizsiNabidkySazbaDPH", - "HodnotaNejnizsiNabidkyProcentniSazbaDPH", - "RocniCiMesicniHodnotaPocetRoku", - "RocniCiMesicniHodnotaPocetMesicu", - "SubdodavkyHodnotaBezDPH", - "SubdodavkyMena", - "SubdodavkyPomer", - "PlatnyFormular" - ], - "dates": [ - "DatumZadaniVZ" - ] - }, - "VerejnaZakazka": { - "table": "vz", - "header": [ - "EvidencniCisloVZnaVVZ", - "CisloFormulareNaVVZ", - "DruhFormulare", - "TypFormulare", - "VZdelenaNaCasti", - "ZadavatelICO", - "DodavatelICO", - "LimitVZ", - "DatumOdeslaniFormulareNaVVZ", - "DatumUverejneni", - "ZadavatelUredniNazev", - "ZadavatelDruh", - "ZadavatelHlavniPredmetCinnosti", - "ZadavatelZadavaJmenemJinych", - "NazevVZ", - "DruhVZ", - "KategorieSluzeb", - "HlavniMistoPlneni", - "StrucnyPopisVZ", - "CPVhlavni", - "CPVdoplnkovy1", - "CPVdoplnkovy2", - "DruhyPredmetCPVhlavni", - "DruhyPredmetCPVdoplnkovy1", - "DruhyPredmetCPVdoplnkovy2", - "TretiPredmetCPVhlavni", - "TretiPredmetCPVdoplnkovy1", - "TretiPredmetCPVdoplnkovy2", - "CtvrtyPredmetCPVhlavni", - "CtvrtyPredmetCPVdoplnkovy1", - "CtvrtyPredmetCPVdoplnkovy2", - "PatyPredmetCPVhlavni", - "PatyPredmetCPVdoplnkovy1", - "PatyPredmetCPVdoplnkovy2", - "NaVZseVztahujeGPA", - "CelkovaKonecnaHodnotaVZ", - "CelkovaKonecnaHodnotaVZmena", - "CelkovaKonecnaHodnotaVZsazbaDPH", - "CelkovaKonecnaHodnotaVZprocentniSazbaDPH", - "NejnizsiNabidkaVzataVuvahu", - "NejnizsiNabidkaVzataVuvahuMena", - "NejnizsiNabidkaVzataVuvahuSazbaDPH", - "NejnizsiNabidkaVzataVuvahuProcentniSazbaDPH", - "NejvyssiNabidkaVzataVuvahu", - "DruhRizeni", - "HlavniKriteriaProZadaniZakazky", - "Kriterium1", - "VahaKriteria1", - "Kriterium2", - "VahaKriteria2", - "Kriterium3", - "VahaKriteria3", - "Kriterium4", - "VahaKriteria4", - "Kriterium5", - "VahaKriteria5", - "Kriterium6", - "VahaKriteria6", - "Kriterium7", - "VahaKriteria7", - "Kriterium8", - "VahaKriteria8", - "Kriterium9", - "VahaKriteria9", - "Kriterium10", - "VahaKriteria10", - "BylaPouzitaElektronickaDrazba", - "ZakazkaSeVztahujeKprojektuFinZes", - "ProjektyCiprogramy", - "OdhadovanaHodnotaVZbezDPH", - "OdhadovanaHodnotaVZmena", - "OdhadovanaHodnotaVZrozsahOd", - "OdhadovanaHodnotaVZrozsahDo", - "OdhadovanaHodnotaVZrozsahMena", - "PlatnyFormular" - ], - "dates": [ - "DatumOdeslaniFormulareNaVVZ", - "DatumUverejneni" - ] - } - }, "zzvz": { "Zadani": { "table": "zadani_vz", - "header": [ - "IDZakazky", - "EvidencniCisloVZnaVVZ", - "CisloFormulareNaVVZ", - "DruhFormulare", - "IDZadani", - "CisloCastiZadaniVZ", - "NazevCastiVZ", - "ZadaniCastiZakazky", - "InformaceONezadaniCastiZakazky", - "DatumZadaniVZ", - "PocetObdrzenychNabidek", - "PuvodniOdhadovanaCelkovaHodnotaVZ", - "PuvodniOdhadovanaCelkovaHodnotaVZMena", - "CelkovaKonecnaHodnotaVZzaZadani", - "CelkovaKonecnaHodnotaVZmenaZaZadani", - "HodnotaNejnizsiNabidky", - "HodnotaNejnizsiNabidkyMena", - "HodnotaNejvyssiNabidky", - "SubdodavkyHodnotaBezDPH", - "SubdodavkyMena", - "SubdodavkyPomer", - "DatumOdeslaniFormulareNaVVZ", - "PlatnyFormular" - ], - "dates": [ - "DatumZadaniVZ", - "DatumOdeslaniFormulareNaVVZ" - ] + "header": { + "ID_Zakazky": "id_zakazky", + "EvidencniCisloVZnaVVZ": "evidencni_cislo_vz_na_vvz", + "CisloFormulareNaVVZ": "cislo_formulare_na_vvz", + "DruhFormulare": "druh_formulare", + "ID_Zadani": "id_zadani", + "CisloCastiZadaniVZ": "cislo_casti_zadani_vz", + "NazevCastiVZ": "nazev_casti_vz", + "ZadaniCastiZakazky": "zadani_casti_zakazky", + "InformaceONezadaniCastiZakazky": "informace_o_nezadani_casti_zakazky", + "DatumZadaniVZ": "datum_zadani_vz", + "PocetObdrzenychNabidek": "pocet_obdrzenych_nabidek", + "PuvodniOdhadovanaCelkovaHodnotaVZ": "puvodni_odhadovana_celkova_hodnota_vz", + "PuvodniOdhadovanaCelkovaHodnotaVZMena": "puvodni_odhadovana_celkova_hodnota_vz_mena", + "CelkovaKonecnaHodnotaVZzaZadani": "celkova_konecna_hodnota_vz_za_zadani", + "CelkovaKonecnaHodnotaVZmenaZaZadani": "celkova_konecna_hodnota_vz_mena_za_zadani", + "HodnotaNejnizsiNabidky": "hodnota_nejnizsi_nabidky", + "HodnotaNejnizsiNabidkyMena": "hodnota_nejnizsi_nabidky_mena", + "HodnotaNejvyssiNabidky": "hodnota_nejvyssi_nabidky", + "SubdodavkyHodnotaBezDPH": "subdodavky_hodnota_bez_dph", + "SubdodavkyMena": "subdodavky_mena", + "SubdodavkyPomer": "subdodavky_pomer", + "DatumOdeslaniFormulareNaVVZ": "datum_odeslani_formulare_na_vvz", + "PlatnyFormular": "platny_formular" + } }, "CastiVZ": { "table": "casti_vz", - "header": [ - "IDZakazky", - "EvidencniCisloVZnaVVZ", - "CisloFormulareNaVVZ", - "DruhFormulare", - "IDCastiVZ", - "CisloCastiVZ", - "NazevCastiVZ", - "PopisCastiVZ", - "PredpokladanaCelkovaHodnotaCastiVZ", - "PredpokladanaCelkovaHodnotaCastiVZMena", - "HlavniMistoPlneniNUTS", - "HlavniMistoPlneni", - "CPVkod", - "ZakazkaSeVztahujeKprojektuFinZes", - "ProjektyCiProgramyFinZes", - "DatumOdeslaniFormulareNaVVZ", - "PlatnyFormular" - ], - "dates": [ - "DatumOdeslaniFormulareNaVVZ" - ] + "header": { + "ID_Zakazky": "id_zakazky", + "EvidencniCisloVZnaVVZ": "evidencni_cislo_vz_na_vvz", + "CisloFormulareNaVVZ": "cislo_formulare_na_vvz", + "DruhFormulare": "druh_formulare", + "ID_CastiVZ": "id_casti_vz", + "CisloCastiVZ": "cislo_casti_vz", + "NazevCastiVZ": "nazev_casti_vz", + "PopisCastiVZ": "popis_casti_vz", + "PredpokladanaCelkovaHodnotaCastiVZ": "predpokladana_celkova_hodnota_casti_vz", + "PredpokladanaCelkovaHodnotaCastiVZMena": "predpokladana_celkova_hodnota_casti_vz_mena", + "HlavniMistoPlneniNUTS": "hlavni_misto_plneni_nuts", + "HlavniMistoPlneni": "hlavni_misto_plneni", + "CPVkod": "cpv_kod", + "ZakazkaSeVztahujeKprojektuFinZes": "zakazka_se_vztahuje_kprojektu_fin_zes", + "ProjektyCiProgramyFinZes": "projekty_ci_programy_fin_zes", + "DatumOdeslaniFormulareNaVVZ": "datum_odeslani_formulare_na_vvz", + "PlatnyFormular": "platny_formular" + } }, "Dodavatele": { "table": "dodavatele", - "header": [ - "IDZakazky", - "EvidencniCisloVZnaVVZ", - "CisloFormulareNaVVZ", - "DruhFormulare", - "IDZadani", - "CisloCastiZadaniVZ", - "NazevCastiVZ", - "DodavatelICO", - "DodavatelNazev", - "DodavatelPostovniAdresa", - "DodavatelObec", - "DodavatelPSC", - "DodavatelStat", - "DodavatelWww", - "DatumOdeslaniFormulareNaVVZ", - "PlatnyFormular" - ], - "dates": [ - "DatumOdeslaniFormulareNaVVZ" - ] + "header": { + "ID_Zakazky": "id_zakazky", + "EvidencniCisloVZnaVVZ": "evidencni_cislo_vz_na_vvz", + "CisloFormulareNaVVZ": "cislo_formulare_na_vvz", + "DruhFormulare": "druh_formulare", + "ID_Zadani": "id_zadani", + "CisloCastiZadaniVZ": "cislo_casti_zadani_vz", + "NazevCastiVZ": "nazev_casti_vz", + "DodavatelICO": "dodavatel_ico", + "DodavatelNazev": "dodavatel_nazev", + "DodavatelPostovniAdresa": "dodavatel_postovni_adresa", + "DodavatelObec": "dodavatel_obec", + "DodavatelPSC": "dodavatel_psc", + "DodavatelStat": "dodavatel_stat", + "DodavatelWww": "dodavatel_www", + "DatumOdeslaniFormulareNaVVZ": "datum_odeslani_formulare_na_vvz", + "PlatnyFormular": "platny_formular" + } }, "VZ": { "table": "vz", - "header": [ - "IDZakazky", - "EvidencniCisloVZnaVVZ", - "CisloFormulareNaVVZ", - "DruhFormulare", - "TypFormulare", - "VZdelenaNaCasti", - "ZadavatelICO", - "LimitVZ", - "DatumOdeslaniFormulareNaVVZ", - "DatumUverejneni", - "ZadavatelUredniNazev", - "ZadavatelDruh", - "ZadavatelHlavniPredmetCinnosti", - "ZakazkaZahrnujeSpolecneZadavaniZakazek", - "ZakazkuZadavaCentralniZadavatel", - "ZadavatelProfilURL", - "ZadavatelProfilURLPlatnost", - "ZadavatelProfilZruseniTyp", - "ZadavatelProfilURLNova", - "DatumZruseniCiZneaktivneniProfilu", - "NazevVZ", - "DruhVZ", - "StrucnyPopisVZ", - "CPVhlavni", - "CPVdoplnkovy1", - "NaVZseVztahujeGPA", - "CelkovaKonecnaHodnotaVZ", - "CelkovaKonecnaHodnotaVZmena", - "NejnizsiNabidkaVzataVuvahu", - "NejnizsiNabidkaVzataVuvahuMena", - "NejvyssiNabidkaVzataVuvahu", - "DruhRizeni", - "BylaPouzitaElektronickaDrazba", - "OdhadovanaHodnotaVZbezDPH", - "OdhadovanaHodnotaVZmena", - "ZadavatelKontaktniOsoba", - "ZadavatelEmail", - "ZadavatelTelefon", - "LhutaProDoruceniNabidek", - "OteviraniNabidekDatumCas", - "OteviraniNabidekMisto", - "OteviraniNabidekOpravneneOsobyDalsiInfo", - "UchazecVazanNabidkouDo", - "UchazecVazanNabidkouDobaMesice", - "PlatnyFormular", - "PravidelnePredbezneOznameni", - "PravidelnePredbezneOznameniVyzvaKSoutezi", - "PredbezneOznameni", - "PredbezneOznameniVyzvaKSoutezi", - "SystemKvalifikace", - "SystemKvalifikaceVyzvaKSoutezi", - "OznameniOZahajeniZR", - "OznameniOVysledkuZR", - "OznameniOVysledkuKS" - ], - "dates": [ - "DatumOdeslaniFormulareNaVVZ", - "DatumUverejneni", - "DatumZruseniCiZneaktivneniProfilu" - ] + "header": { + "ID_Zakazky": "id_zakazky", + "EvidencniCisloVZnaVVZ": "evidencni_cislo_vz_na_vvz", + "CisloFormulareNaVVZ": "cislo_formulare_na_vvz", + "DruhFormulare": "druh_formulare", + "TypFormulare": "typ_formulare", + "VZdelenaNaCasti": "vz_delena_na_casti", + "ZadavatelICO": "zadavatel_ico", + "LimitVZ": "limit_vz", + "DatumOdeslaniFormulareNaVVZ": "datum_odeslani_formulare_na_vvz", + "DatumUverejneni": "datum_uverejneni", + "ZadavatelUredniNazev": "zadavatel_uredni_nazev", + "ZadavatelDruh": "zadavatel_druh", + "ZadavatelHlavniPredmetCinnosti": "zadavatel_hlavni_predmet_cinnosti", + "ZakazkaZahrnujeSpolecneZadavaniZakazek": "zakazka_zahrnuje_spolecne_zadavani_zakazek", + "ZakazkuZadavaCentralniZadavatel": "zakazku_zadava_centralni_zadavatel", + "ZadavatelProfilURL": "zadavatel_profil_url", + "ZadavatelProfilURLPlatnost": "zadavatel_profil_url_platnost", + "ZadavatelProfilZruseniTyp": "zadavatel_profil_zruseni_typ", + "ZadavatelProfilURLNova": "zadavatel_profil_url_nova", + "DatumZruseniCiZneaktivneniProfilu": "datum_zruseni_ci_zneaktivneni_profilu", + "NazevVZ": "nazev_vz", + "DruhVZ": "druh_vz", + "StrucnyPopisVZ": "strucny_popis_vz", + "CPVhlavni": "cpv_hlavni", + "CPVdoplnkovy1": "cpv_doplnkovy1", + "NaVZseVztahujeGPA": "na_vz_se_vztahuje_gpa", + "CelkovaKonecnaHodnotaVZ": "celkova_konecna_hodnota_vz", + "CelkovaKonecnaHodnotaVZmena": "celkova_konecna_hodnota_vz_mena", + "NejnizsiNabidkaVzataVuvahu": "nejnizsi_nabidka_vzata_vuvahu", + "NejnizsiNabidkaVzataVuvahuMena": "nejnizsi_nabidka_vzata_vuvahu_mena", + "NejvyssiNabidkaVzataVuvahu": "nejvyssi_nabidka_vzata_vuvahu", + "DruhRizeni": "druh_rizeni", + "BylaPouzitaElektronickaDrazba": "byla_pouzita_elektronicka_drazba", + "OdhadovanaHodnotaVZbezDPH": "odhadovana_hodnota_vz_bez_dph", + "OdhadovanaHodnotaVZmena": "odhadovana_hodnota_vz_mena", + "ZadavatelKontaktniOsoba": "zadavatel_kontaktni_osoba", + "ZadavatelEmail": "zadavatel_email", + "ZadavatelTelefon": "zadavatel_telefon", + "LhutaProDoruceniNabidek": "lhuta_pro_doruceni_nabidek", + "OteviraniNabidekDatumCas": "otevirani_nabidek_datum_cas", + "OteviraniNabidekMisto": "otevirani_nabidek_misto", + "OteviraniNabidekOpravneneOsobyDalsiInfo": "otevirani_nabidek_opravnene_osoby_dalsi_info", + "UchazecVazanNabidkouDo": "uchazec_vazan_nabidkou_do", + "UchazecVazanNabidkouDobaMesice": "uchazec_vazan_nabidkou_doba_mesice", + "PlatnyFormular": "platny_formular", + "PravidelnePredbezneOznameni": "pravidelne_predbezne_oznameni", + "PravidelnePredbezneOznameniVyzvaKSoutezi": "pravidelne_predbezne_oznameni_vyzva_k_soutezi", + "PredbezneOznameni": "predbezne_oznameni", + "PredbezneOznameniVyzvaKSoutezi": "predbezne_oznameni_vyzva_k_soutezi", + "SystemKvalifikace": "system_kvalifikace", + "SystemKvalifikaceVyzvaKSoutezi": "system_kvalifikace_vyzva_k_soutezi", + "OznameniOZahajeniZR": "oznameni_o_zahajeni_zr", + "OznameniOVysledkuZR": "oznameni_o_vysledku_zr", + "OznameniOVysledkuKS": "oznameni_o_vysledku_ks" + } }, "HodnoticiKriteria": { "table": "kriteria_vz", - "header": [ - "IDZakazky", - "IDPopisuCastiZakazky", - "EvidencniCisloVZnaVVZ", - "CisloFormulareNaVVZ", - "DruhFormulare", - "CisloCastiVZ", - "NazevCastiVZ", - "PoradiKriteria", - "KriteriumZadaniZakazky", - "NazevKriteria", - "VahaKriteria", - "DatumOdeslaniFormulareNaVVZ", - "PlatnyFormular" - ], - "dates": [ - "DatumOdeslaniFormulareNaVVZ" - ] + "header": { + "ID_Zakazky": "id_zakazky", + "ID_PopisuCastiZakazky": "id_popisu_casti_zakazky", + "EvidencniCisloVZnaVVZ": "evidencni_cislo_vz_na_vvz", + "CisloFormulareNaVVZ": "cislo_formulare_na_vvz", + "DruhFormulare": "druh_formulare", + "CisloCastiVZ": "cislo_casti_vz", + "NazevCastiVZ": "nazev_casti_vz", + "PoradiKriteria": "poradi_kriteria", + "KriteriumZadaniZakazky": "kriterium_zadani_zakazky", + "NazevKriteria": "nazev_kriteria", + "VahaKriteria": "vaha_kriteria", + "DatumOdeslaniFormulareNaVVZ": "datum_odeslani_formulare_na_vvz", + "PlatnyFormular": "platny_formular" + } } } } \ No newline at end of file diff --git a/data/zakazky/schema.py b/data/zakazky/schema.py index e8967e6..ac647f5 100644 --- a/data/zakazky/schema.py +++ b/data/zakazky/schema.py @@ -12,228 +12,228 @@ meta = MetaData() schema = [ - Table( - "etrziste_casti_vz", - meta, - Column("vz_systemove_cislo", Text, nullable=False), - Column("cast_vz_cislo", SmallInteger, nullable=False), - Column("smluvni_cena_vcetne_dph", Numeric(14, 2), nullable=True), - Column("smluvni_cena_bez_dph", Numeric(14, 2), nullable=True), - Column("smluvni_cena_sazba_dph", Numeric(14, 2), nullable=True), - Column("smluvni_cena_mena", Text, nullable=True), # TODO: enum? - ), - Table( - "etrziste_polozky_vz", - meta, - Column("vz_systemove_cislo", Text, nullable=False), - Column("nipez_kod", Text, nullable=True), - Column("nipez_nazev", Text, nullable=True), - Column("nipez_povinnost_pro_etrziste", Text, nullable=True), - Column("nipez_nazev_vlastnosti", Text, nullable=True), - Column("nipez_datovy_typ_vlastnosti", Text, nullable=True), - Column("nipez_hodnota_vlastnosti", Text, nullable=True), - Column("nipez_merna_jednotka_vlastnosti", Text, nullable=True), - Column("nipez_operator_vlastnosti", Text, nullable=True), - ), - Table( - "etrziste_kriteria_vz", - meta, - Column("vz_systemove_cislo", Text, nullable=False), - Column("dilci_hodnotici_kriterium", Text, nullable=False), - Column("dilci_hodnotici_kriterium_vaha", Numeric(5, 2), nullable=False), - Column("dilci_kriterium_ciselne_vyjadritelne", Text, nullable=True), - Column("dilci_kriterium_predmetem_eaukce", Text, nullable=True), - Column( - "dilci_kriterium_zadavatel_pozadoval_vlozeni_nabidkovych_hodnot", - Text, - nullable=True, - ), - Column("subkriterium_nabidkove_ceny", Text, nullable=True), - Column("subkriterium_nabidkove_ceny_vaha", Numeric(5, 2), nullable=True), - Column("subkriterium_dilciho_kriteria", Text, nullable=True), - Column("subkriterium_dilciho_kriteria_vaha", Numeric(5, 2), nullable=True), - Column("subkriterium_ciselne_vyjadritelne", Text, nullable=True), - Column("subkriterium_predmetem_eaukce", Text, nullable=True), - Column( - "subkriterium_zadavatel_pozadoval_vlozeni_nabidkovych_hodnot", - Text, - nullable=True, - ), - ), - Table( - "etrziste_dodavatele", - meta, - Column("vz_systemove_cislo", Text, nullable=False), - Column("cast_vz_cislo", SmallInteger, nullable=False), - Column("datum_uzavreni_smlouvy", DateTime, nullable=True), - Column("dodavatel_uredni_nazev", Text, nullable=False), - Column("dodavatel_ico", Integer, nullable=True, index=True), - Column("dodavatel_stat", Text, nullable=False), - ), - Table( - "etrziste_vz", - meta, - Column("nazev_etrziste", Text, nullable=False), - Column("vz_systemove_cislo", Text, nullable=False), - Column("nazev_vz", Text, nullable=False), - Column("vz_stav", Text, nullable=False), - Column("vz_druh", Text, nullable=False), - Column("vz_typ", Text, nullable=True), - Column("druh_zadavaci_rizeni", Text, nullable=True), - Column("predpokladana_hodnota_vz", Numeric(14, 2), nullable=False), - Column("celkova_smluvni_cena_bez_dph", Numeric(14, 2), nullable=True), - Column("celkova_smluvni_cena_vcetne_dph", Numeric(14, 2), nullable=True), - Column("celkova_smluvni_cena_mena", Text, nullable=True), - Column("zadavatel_nazev", Text, nullable=False), - Column("zadavatel_ico", Integer, nullable=False, index=True), - Column("zadavatel_kategorie", Text, nullable=False), - Column("vysledek_zadavaciho_rizeni", Text, nullable=False), - Column("datum_uzavreni_smlouvy", Date, nullable=True), - Column("delena_na_casti", Text, nullable=False), - Column("pocet_casti", Text, nullable=True), - Column("pocet_polozek_vz", Text, nullable=False), - Column("metoda_hodnoceni", Text, nullable=False), - Column("zakladni_hodnotici_kriterium", Text, nullable=False), - Column("zruseni_vz", Text, nullable=True), - Column("datum_zruseni_zadavaciho_rizeni", Date, nullable=True), - Column("byla_do_zr_zarazena_eaukce", Text, nullable=True), - Column("pocet_vyzvanych_dodavatelu", Text, nullable=True), - Column("pocet_obdrzenych_nabidek", Text, nullable=True), - Column("pocet_hodnocenych_nabidek", Text, nullable=True), - Column("namitky_pocet", Text, nullable=True), - Column("namitky_vyhoveno", Text, nullable=True), - Column("prezkum_ukonu", Text, nullable=True), - Column("prezkumnych_rizeni_pocet", Text, nullable=True), - Column("zadosti_o_dodatecne_informace_pocet", Text, nullable=True), - Column("dodavatel_nazev", Text, nullable=True), - Column("dodavatel_ico", Integer, nullable=True, index=True), - ), - Table( - "vvz_casti_vz", - meta, - Column("evidencni_cislo_vz_na_vvz", Text, nullable=False), - Column("cislo_formulare_na_vvz", Text, nullable=True), - Column("cislo_casti_zadani_vz", Text, nullable=True), - Column("nazev_casti_vz", Text, nullable=True), - Column("datum_zadani_vz", Date, nullable=True), - Column("pocet_obdrzenych_nabidek", Integer, nullable=True), - Column("dodavatel_nazev", Text, nullable=True), - Column("dodavatel_ico_ze_zadani", Integer, nullable=True, index=True), - Column("dodavatel_postovni_adresa", Text, nullable=True), - Column("dodavatel_obec", Text, nullable=True), - Column("dodavatel_psc", Text, nullable=True), - Column("dodavatel_stat", Text, nullable=True), - Column("dodavatel_www", Text, nullable=True), - Column("puvodni_odhadovana_celkova_hodnota_vz", Numeric(16, 2), nullable=True), - Column("puvodni_odhadovana_celkova_hodnota_vz_mena", Text, nullable=True), - Column("puvodni_odhadovana_celkova_hodnota_vz_sazba_dph", Text, nullable=True), - Column( - "puvodni_odhadovana_celkova_hodnota_vz_procentni_sazba_dph", - Numeric(4, 2), - nullable=True, - ), - Column("celkova_konecna_hodnota_vz_za_zadani", Text, nullable=True), - Column("celkova_konecna_hodnota_vz_mena_za_zadani", Text, nullable=True), - Column("celkova_konecna_hodnota_vz_sazba_dph_za_zadani", Text, nullable=True), - Column( - "celkova_konecna_hodnota_vz_procentni_sazba_dph_za_zadani", - Text, - nullable=True, - ), - Column("hodnota_nejnizsi_nabidky", Numeric(14, 2), nullable=True), - Column("hodnota_nejnizsi_nabidky_mena", Text, nullable=True), - Column("hodnota_nejnizsi_nabidky_sazba_dph", Text, nullable=True), - Column( - "hodnota_nejnizsi_nabidky_procentni_sazba_dph", Numeric(4, 2), nullable=True - ), - Column("rocni_ci_mesicni_hodnota_pocet_roku", Integer, nullable=True), - Column("rocni_ci_mesicni_hodnota_pocet_mesicu", Integer, nullable=True), - Column("subdodavky_hodnota_bez_dph", Numeric(14, 2), nullable=True), - Column("subdodavky_mena", Text, nullable=True), - Column("subdodavky_pomer", Numeric(5, 2), nullable=True), - Column("platny_formular", Boolean, nullable=False), - ), - Table( - "vvz_vz", - meta, - Column("evidencni_cislo_vz_na_vvz", Text, nullable=False), - Column("cislo_formulare_na_vvz", Text, nullable=True), - Column("druh_formulare", Text, nullable=False), - Column("typ_formulare", Text, nullable=False), - Column("vz_delena_na_casti", Text, nullable=True), - Column("zadavatel_ico", Integer, nullable=True, index=True), - Column("dodavatel_ico", Integer, nullable=True, index=True), - Column("limit_vz", Text, nullable=True), - Column("datum_odeslani_formulare_na_vvz", Date, nullable=False), - Column("datum_uverejneni", Date, nullable=False), - Column("zadavatel_uredni_nazev", Text, nullable=False), - Column("zadavatel_druh", Text, nullable=True), - Column("zadavatel_hlavni_predmet_cinnosti", Text, nullable=True), - Column("zadavatel_zadava_jmenem_jinych", Text, nullable=True), - Column("nazev_vz", Text, nullable=True), - Column("druh_vz", Text, nullable=True), - Column("kategorie_sluzeb", Text, nullable=True), - Column("hlavni_misto_plneni", Text, nullable=True), - Column("strucny_popis_vz", Text, nullable=True), - Column("cpv_hlavni", Text, nullable=True), - Column("cpv_doplnkovy1", Text, nullable=True), - Column("cpv_doplnkovy2", Text, nullable=True), - Column("druhy_predmet_cpv_hlavni", Text, nullable=True), - Column("druhy_predmet_cpv_doplnkovy1", Text, nullable=True), - Column("druhy_predmet_cpv_doplnkovy2", Text, nullable=True), - Column("treti_predmet_cpv_hlavni", Text, nullable=True), - Column("treti_predmet_cpv_doplnkovy1", Text, nullable=True), - Column("treti_predmet_cpv_doplnkovy2", Text, nullable=True), - Column("ctvrty_predmet_cpv_hlavni", Text, nullable=True), - Column("ctvrty_predmet_cpv_doplnkovy1", Text, nullable=True), - Column("ctvrty_predmet_cpv_doplnkovy2", Text, nullable=True), - Column("paty_predmet_cpv_hlavni", Text, nullable=True), - Column("paty_predmet_cpv_doplnkovy1", Text, nullable=True), - Column("paty_predmet_cpv_doplnkovy2", Text, nullable=True), - Column("na_vz_se_vztahuje_gpa", Text, nullable=True), - Column("celkova_konecna_hodnota_vz", Text, nullable=True), - Column("celkova_konecna_hodnota_vz_mena", Text, nullable=True), - Column("celkova_konecna_hodnota_vz_sazba_dph", Text, nullable=True), - Column("celkova_konecna_hodnota_vz_procentni_sazba_dph", Text, nullable=True), - Column("nejnizsi_nabidka_vzata_vuvahu", Text, nullable=True), - Column("nejnizsi_nabidka_vzata_vuvahu_mena", Text, nullable=True), - Column("nejnizsi_nabidka_vzata_vuvahu_sazba_dph", Text, nullable=True), - Column( - "nejnizsi_nabidka_vzata_vuvahu_procentni_sazba_dph", Text, nullable=True - ), - Column("nejvyssi_nabidka_vzata_vuvahu", Text, nullable=True), - Column("druh_rizeni", Text, nullable=True), - Column("hlavni_kriteria_pro_zadani_zakazky", Text, nullable=True), - Column("kriterium1", Text, nullable=True), - Column("vaha_kriteria1", Text, nullable=True), - Column("kriterium2", Text, nullable=True), - Column("vaha_kriteria2", Text, nullable=True), - Column("kriterium3", Text, nullable=True), - Column("vaha_kriteria3", Text, nullable=True), - Column("kriterium4", Text, nullable=True), - Column("vaha_kriteria4", Text, nullable=True), - Column("kriterium5", Text, nullable=True), - Column("vaha_kriteria5", Text, nullable=True), - Column("kriterium6", Text, nullable=True), - Column("vaha_kriteria6", Text, nullable=True), - Column("kriterium7", Text, nullable=True), - Column("vaha_kriteria7", Text, nullable=True), - Column("kriterium8", Text, nullable=True), - Column("vaha_kriteria8", Text, nullable=True), - Column("kriterium9", Text, nullable=True), - Column("vaha_kriteria9", Text, nullable=True), - Column("kriterium10", Text, nullable=True), - Column("vaha_kriteria10", Text, nullable=True), - Column("byla_pouzita_elektronicka_drazba", Text, nullable=True), - Column("zakazka_se_vztahuje_kprojektu_fin_zes", Text, nullable=True), - Column("projekty_ciprogramy", Text, nullable=True), - Column("odhadovana_hodnota_vz_bez_dph", Numeric(14, 2), nullable=True), - Column("odhadovana_hodnota_vz_mena", Text, nullable=True), - Column("odhadovana_hodnota_vz_rozsah_od", Numeric(14, 2), nullable=True), - Column("odhadovana_hodnota_vz_rozsah_do", Numeric(14, 2), nullable=True), - Column("odhadovana_hodnota_vz_rozsah_mena", Text, nullable=True), - Column("platny_formular", Boolean, nullable=False), - ), + # Table( + # "etrziste_casti_vz", + # meta, + # Column("vz_systemove_cislo", Text, nullable=False), + # Column("cast_vz_cislo", SmallInteger, nullable=False), + # Column("smluvni_cena_vcetne_dph", Numeric(14, 2), nullable=True), + # Column("smluvni_cena_bez_dph", Numeric(14, 2), nullable=True), + # Column("smluvni_cena_sazba_dph", Numeric(14, 2), nullable=True), + # Column("smluvni_cena_mena", Text, nullable=True), # TODO: enum? + # ), + # Table( + # "etrziste_polozky_vz", + # meta, + # Column("vz_systemove_cislo", Text, nullable=False), + # Column("nipez_kod", Text, nullable=True), + # Column("nipez_nazev", Text, nullable=True), + # Column("nipez_povinnost_pro_etrziste", Text, nullable=True), + # Column("nipez_nazev_vlastnosti", Text, nullable=True), + # Column("nipez_datovy_typ_vlastnosti", Text, nullable=True), + # Column("nipez_hodnota_vlastnosti", Text, nullable=True), + # Column("nipez_merna_jednotka_vlastnosti", Text, nullable=True), + # Column("nipez_operator_vlastnosti", Text, nullable=True), + # ), + # Table( + # "etrziste_kriteria_vz", + # meta, + # Column("vz_systemove_cislo", Text, nullable=False), + # Column("dilci_hodnotici_kriterium", Text, nullable=False), + # Column("dilci_hodnotici_kriterium_vaha", Numeric(5, 2), nullable=False), + # Column("dilci_kriterium_ciselne_vyjadritelne", Text, nullable=True), + # Column("dilci_kriterium_predmetem_eaukce", Text, nullable=True), + # Column( + # "dilci_kriterium_zadavatel_pozadoval_vlozeni_nabidkovych_hodnot", + # Text, + # nullable=True, + # ), + # Column("subkriterium_nabidkove_ceny", Text, nullable=True), + # Column("subkriterium_nabidkove_ceny_vaha", Numeric(5, 2), nullable=True), + # Column("subkriterium_dilciho_kriteria", Text, nullable=True), + # Column("subkriterium_dilciho_kriteria_vaha", Numeric(5, 2), nullable=True), + # Column("subkriterium_ciselne_vyjadritelne", Text, nullable=True), + # Column("subkriterium_predmetem_eaukce", Text, nullable=True), + # Column( + # "subkriterium_zadavatel_pozadoval_vlozeni_nabidkovych_hodnot", + # Text, + # nullable=True, + # ), + # ), + # Table( + # "etrziste_dodavatele", + # meta, + # Column("vz_systemove_cislo", Text, nullable=False), + # Column("cast_vz_cislo", SmallInteger, nullable=False), + # Column("datum_uzavreni_smlouvy", DateTime, nullable=True), + # Column("dodavatel_uredni_nazev", Text, nullable=False), + # Column("dodavatel_ico", Integer, nullable=True, index=True), + # Column("dodavatel_stat", Text, nullable=False), + # ), + # Table( + # "etrziste_vz", + # meta, + # Column("nazev_etrziste", Text, nullable=False), + # Column("vz_systemove_cislo", Text, nullable=False), + # Column("nazev_vz", Text, nullable=False), + # Column("vz_stav", Text, nullable=False), + # Column("vz_druh", Text, nullable=False), + # Column("vz_typ", Text, nullable=True), + # Column("druh_zadavaci_rizeni", Text, nullable=True), + # Column("predpokladana_hodnota_vz", Numeric(14, 2), nullable=False), + # Column("celkova_smluvni_cena_bez_dph", Numeric(14, 2), nullable=True), + # Column("celkova_smluvni_cena_vcetne_dph", Numeric(14, 2), nullable=True), + # Column("celkova_smluvni_cena_mena", Text, nullable=True), + # Column("zadavatel_nazev", Text, nullable=False), + # Column("zadavatel_ico", Integer, nullable=False, index=True), + # Column("zadavatel_kategorie", Text, nullable=False), + # Column("vysledek_zadavaciho_rizeni", Text, nullable=False), + # Column("datum_uzavreni_smlouvy", Date, nullable=True), + # Column("delena_na_casti", Text, nullable=False), + # Column("pocet_casti", Text, nullable=True), + # Column("pocet_polozek_vz", Text, nullable=False), + # Column("metoda_hodnoceni", Text, nullable=False), + # Column("zakladni_hodnotici_kriterium", Text, nullable=False), + # Column("zruseni_vz", Text, nullable=True), + # Column("datum_zruseni_zadavaciho_rizeni", Date, nullable=True), + # Column("byla_do_zr_zarazena_eaukce", Text, nullable=True), + # Column("pocet_vyzvanych_dodavatelu", Text, nullable=True), + # Column("pocet_obdrzenych_nabidek", Text, nullable=True), + # Column("pocet_hodnocenych_nabidek", Text, nullable=True), + # Column("namitky_pocet", Text, nullable=True), + # Column("namitky_vyhoveno", Text, nullable=True), + # Column("prezkum_ukonu", Text, nullable=True), + # Column("prezkumnych_rizeni_pocet", Text, nullable=True), + # Column("zadosti_o_dodatecne_informace_pocet", Text, nullable=True), + # Column("dodavatel_nazev", Text, nullable=True), + # Column("dodavatel_ico", Integer, nullable=True, index=True), + # ), + # Table( + # "vvz_casti_vz", + # meta, + # Column("evidencni_cislo_vz_na_vvz", Text, nullable=False), + # Column("cislo_formulare_na_vvz", Text, nullable=True), + # Column("cislo_casti_zadani_vz", Text, nullable=True), + # Column("nazev_casti_vz", Text, nullable=True), + # Column("datum_zadani_vz", Date, nullable=True), + # Column("pocet_obdrzenych_nabidek", Integer, nullable=True), + # Column("dodavatel_nazev", Text, nullable=True), + # Column("dodavatel_ico_ze_zadani", Integer, nullable=True, index=True), + # Column("dodavatel_postovni_adresa", Text, nullable=True), + # Column("dodavatel_obec", Text, nullable=True), + # Column("dodavatel_psc", Text, nullable=True), + # Column("dodavatel_stat", Text, nullable=True), + # Column("dodavatel_www", Text, nullable=True), + # Column("puvodni_odhadovana_celkova_hodnota_vz", Numeric(16, 2), nullable=True), + # Column("puvodni_odhadovana_celkova_hodnota_vz_mena", Text, nullable=True), + # Column("puvodni_odhadovana_celkova_hodnota_vz_sazba_dph", Text, nullable=True), + # Column( + # "puvodni_odhadovana_celkova_hodnota_vz_procentni_sazba_dph", + # Numeric(4, 2), + # nullable=True, + # ), + # Column("celkova_konecna_hodnota_vz_za_zadani", Text, nullable=True), + # Column("celkova_konecna_hodnota_vz_mena_za_zadani", Text, nullable=True), + # Column("celkova_konecna_hodnota_vz_sazba_dph_za_zadani", Text, nullable=True), + # Column( + # "celkova_konecna_hodnota_vz_procentni_sazba_dph_za_zadani", + # Text, + # nullable=True, + # ), + # Column("hodnota_nejnizsi_nabidky", Numeric(14, 2), nullable=True), + # Column("hodnota_nejnizsi_nabidky_mena", Text, nullable=True), + # Column("hodnota_nejnizsi_nabidky_sazba_dph", Text, nullable=True), + # Column( + # "hodnota_nejnizsi_nabidky_procentni_sazba_dph", Numeric(4, 2), nullable=True + # ), + # Column("rocni_ci_mesicni_hodnota_pocet_roku", Integer, nullable=True), + # Column("rocni_ci_mesicni_hodnota_pocet_mesicu", Integer, nullable=True), + # Column("subdodavky_hodnota_bez_dph", Numeric(14, 2), nullable=True), + # Column("subdodavky_mena", Text, nullable=True), + # Column("subdodavky_pomer", Numeric(5, 2), nullable=True), + # Column("platny_formular", Boolean, nullable=False), + # ), + # Table( + # "vvz_vz", + # meta, + # Column("evidencni_cislo_vz_na_vvz", Text, nullable=False), + # Column("cislo_formulare_na_vvz", Text, nullable=True), + # Column("druh_formulare", Text, nullable=False), + # Column("typ_formulare", Text, nullable=False), + # Column("vz_delena_na_casti", Text, nullable=True), + # Column("zadavatel_ico", Integer, nullable=True, index=True), + # Column("dodavatel_ico", Integer, nullable=True, index=True), + # Column("limit_vz", Text, nullable=True), + # Column("datum_odeslani_formulare_na_vvz", Date, nullable=False), + # Column("datum_uverejneni", Date, nullable=False), + # Column("zadavatel_uredni_nazev", Text, nullable=False), + # Column("zadavatel_druh", Text, nullable=True), + # Column("zadavatel_hlavni_predmet_cinnosti", Text, nullable=True), + # Column("zadavatel_zadava_jmenem_jinych", Text, nullable=True), + # Column("nazev_vz", Text, nullable=True), + # Column("druh_vz", Text, nullable=True), + # Column("kategorie_sluzeb", Text, nullable=True), + # Column("hlavni_misto_plneni", Text, nullable=True), + # Column("strucny_popis_vz", Text, nullable=True), + # Column("cpv_hlavni", Text, nullable=True), + # Column("cpv_doplnkovy1", Text, nullable=True), + # Column("cpv_doplnkovy2", Text, nullable=True), + # Column("druhy_predmet_cpv_hlavni", Text, nullable=True), + # Column("druhy_predmet_cpv_doplnkovy1", Text, nullable=True), + # Column("druhy_predmet_cpv_doplnkovy2", Text, nullable=True), + # Column("treti_predmet_cpv_hlavni", Text, nullable=True), + # Column("treti_predmet_cpv_doplnkovy1", Text, nullable=True), + # Column("treti_predmet_cpv_doplnkovy2", Text, nullable=True), + # Column("ctvrty_predmet_cpv_hlavni", Text, nullable=True), + # Column("ctvrty_predmet_cpv_doplnkovy1", Text, nullable=True), + # Column("ctvrty_predmet_cpv_doplnkovy2", Text, nullable=True), + # Column("paty_predmet_cpv_hlavni", Text, nullable=True), + # Column("paty_predmet_cpv_doplnkovy1", Text, nullable=True), + # Column("paty_predmet_cpv_doplnkovy2", Text, nullable=True), + # Column("na_vz_se_vztahuje_gpa", Text, nullable=True), + # Column("celkova_konecna_hodnota_vz", Text, nullable=True), + # Column("celkova_konecna_hodnota_vz_mena", Text, nullable=True), + # Column("celkova_konecna_hodnota_vz_sazba_dph", Text, nullable=True), + # Column("celkova_konecna_hodnota_vz_procentni_sazba_dph", Text, nullable=True), + # Column("nejnizsi_nabidka_vzata_vuvahu", Text, nullable=True), + # Column("nejnizsi_nabidka_vzata_vuvahu_mena", Text, nullable=True), + # Column("nejnizsi_nabidka_vzata_vuvahu_sazba_dph", Text, nullable=True), + # Column( + # "nejnizsi_nabidka_vzata_vuvahu_procentni_sazba_dph", Text, nullable=True + # ), + # Column("nejvyssi_nabidka_vzata_vuvahu", Text, nullable=True), + # Column("druh_rizeni", Text, nullable=True), + # Column("hlavni_kriteria_pro_zadani_zakazky", Text, nullable=True), + # Column("kriterium1", Text, nullable=True), + # Column("vaha_kriteria1", Text, nullable=True), + # Column("kriterium2", Text, nullable=True), + # Column("vaha_kriteria2", Text, nullable=True), + # Column("kriterium3", Text, nullable=True), + # Column("vaha_kriteria3", Text, nullable=True), + # Column("kriterium4", Text, nullable=True), + # Column("vaha_kriteria4", Text, nullable=True), + # Column("kriterium5", Text, nullable=True), + # Column("vaha_kriteria5", Text, nullable=True), + # Column("kriterium6", Text, nullable=True), + # Column("vaha_kriteria6", Text, nullable=True), + # Column("kriterium7", Text, nullable=True), + # Column("vaha_kriteria7", Text, nullable=True), + # Column("kriterium8", Text, nullable=True), + # Column("vaha_kriteria8", Text, nullable=True), + # Column("kriterium9", Text, nullable=True), + # Column("vaha_kriteria9", Text, nullable=True), + # Column("kriterium10", Text, nullable=True), + # Column("vaha_kriteria10", Text, nullable=True), + # Column("byla_pouzita_elektronicka_drazba", Text, nullable=True), + # Column("zakazka_se_vztahuje_kprojektu_fin_zes", Text, nullable=True), + # Column("projekty_ciprogramy", Text, nullable=True), + # Column("odhadovana_hodnota_vz_bez_dph", Numeric(14, 2), nullable=True), + # Column("odhadovana_hodnota_vz_mena", Text, nullable=True), + # Column("odhadovana_hodnota_vz_rozsah_od", Numeric(14, 2), nullable=True), + # Column("odhadovana_hodnota_vz_rozsah_do", Numeric(14, 2), nullable=True), + # Column("odhadovana_hodnota_vz_rozsah_mena", Text, nullable=True), + # Column("platny_formular", Boolean, nullable=False), + # ), Table( "zzvz_zadani_vz", meta, @@ -246,7 +246,7 @@ Column("nazev_casti_vz", Text, nullable=True), Column("zadani_casti_zakazky", Text, nullable=True), Column("informace_o_nezadani_casti_zakazky", Text, nullable=True), - Column("datum_zadani_vz", DateTime, nullable=True), + Column("datum_zadani_vz", Date, nullable=True), Column("pocet_obdrzenych_nabidek", Text, nullable=True), Column("puvodni_odhadovana_celkova_hodnota_vz", Numeric(16, 2), nullable=True), Column("puvodni_odhadovana_celkova_hodnota_vz_mena", Text, nullable=True), @@ -258,7 +258,7 @@ Column("subdodavky_hodnota_bez_dph", Numeric(14, 2), nullable=True), Column("subdodavky_mena", Text, nullable=True), Column("subdodavky_pomer", Numeric(5, 2), nullable=True), - Column("datum_odeslani_formulare_na_vvz", DateTime, nullable=False), + Column("datum_odeslani_formulare_na_vvz", Date, nullable=False), Column("platny_formular", Boolean, nullable=False), ), Table( @@ -266,7 +266,7 @@ meta, Column("id_zakazky", Text, nullable=False), Column("evidencni_cislo_vz_na_vvz", Text, nullable=False), - Column("cislo_formulare_na_vvz", Text, nullable=True), + Column("cislo_formulare_na_vvz", Text, nullable=False), Column("druh_formulare", Text, nullable=False), Column("id_casti_vz", Text, nullable=False), Column("cislo_casti_vz", Text, nullable=True), @@ -279,7 +279,7 @@ Column("cpv_kod", Text, nullable=True), Column("zakazka_se_vztahuje_kprojektu_fin_zes", Text, nullable=True), Column("projekty_ci_programy_fin_zes", Text, nullable=True), - Column("datum_odeslani_formulare_na_vvz", DateTime, nullable=False), + Column("datum_odeslani_formulare_na_vvz", Date, nullable=False), Column("platny_formular", Boolean, nullable=False), ), Table( @@ -292,14 +292,14 @@ Column("id_zadani", Text, nullable=False), Column("cislo_casti_zadani_vz", Text, nullable=True), Column("nazev_casti_vz", Text, nullable=True), - Column("dodavatel_ico", Integer, nullable=True, index=True), + Column("dodavatel_ico", Text, nullable=True, index=True), Column("dodavatel_nazev", Text, nullable=False), Column("dodavatel_postovni_adresa", Text, nullable=True), Column("dodavatel_obec", Text, nullable=False), Column("dodavatel_psc", Text, nullable=True), Column("dodavatel_stat", Text, nullable=False), Column("dodavatel_www", Text, nullable=True), - Column("datum_odeslani_formulare_na_vvz", DateTime, nullable=False), + Column("datum_odeslani_formulare_na_vvz", Date, nullable=False), Column("platny_formular", Boolean, nullable=False), ), Table( @@ -311,10 +311,10 @@ Column("druh_formulare", Text, nullable=False), Column("typ_formulare", Text, nullable=False), Column("vz_delena_na_casti", Text, nullable=True), - Column("zadavatel_ico", Integer, nullable=True, index=True), + Column("zadavatel_ico", Text, nullable=True, index=True), Column("limit_vz", Text, nullable=True), - Column("datum_odeslani_formulare_na_vvz", DateTime, nullable=False), - Column("datum_uverejneni", DateTime, nullable=False), + Column("datum_odeslani_formulare_na_vvz", Date, nullable=False), + Column("datum_uverejneni", Date, nullable=False), Column("zadavatel_uredni_nazev", Text, nullable=False), Column("zadavatel_druh", Text, nullable=True), Column("zadavatel_hlavni_predmet_cinnosti", Text, nullable=True), @@ -324,7 +324,7 @@ Column("zadavatel_profil_url_platnost", Text, nullable=True), Column("zadavatel_profil_zruseni_typ", Text, nullable=True), Column("zadavatel_profil_url_nova", Text, nullable=True), - Column("datum_zruseni_ci_zneaktivneni_profilu", DateTime, nullable=True), + Column("datum_zruseni_ci_zneaktivneni_profilu", Date, nullable=True), Column("nazev_vz", Text, nullable=True), Column("druh_vz", Text, nullable=True), Column("strucny_popis_vz", Text, nullable=True), @@ -344,7 +344,7 @@ Column("zadavatel_email", Text, nullable=False), Column("zadavatel_telefon", Text, nullable=True), Column("lhuta_pro_doruceni_nabidek", Text, nullable=True), - Column("otevirani_nabidek_datum_cas", DateTime, nullable=True), + Column("otevirani_nabidek_datum_cas", Date, nullable=True), Column("otevirani_nabidek_misto", Text, nullable=True), Column("otevirani_nabidek_opravnene_osoby_dalsi_info", Text, nullable=True), Column("uchazec_vazan_nabidkou_do", Text, nullable=True), @@ -370,11 +370,11 @@ Column("druh_formulare", Text, nullable=False), Column("cislo_casti_vz", Text, nullable=True), Column("nazev_casti_vz", Text, nullable=True), - Column("poradi_kriteria", Text, nullable=True), + Column("poradi_kriteria", Text, nullable=False), Column("kriterium_zadani_zakazky", Text, nullable=False), Column("nazev_kriteria", Text, nullable=True), Column("vaha_kriteria", Text, nullable=True), - Column("datum_odeslani_formulare_na_vvz", DateTime, nullable=False), + Column("datum_odeslani_formulare_na_vvz", Date, nullable=False), Column("platny_formular", Boolean, nullable=False), ), ] diff --git a/main.py b/main.py index 4f37ad1..422dd15 100644 --- a/main.py +++ b/main.py @@ -139,12 +139,12 @@ def warninger(message, category, filename, lineno, line=None): for file in files: with open(file, "rt", encoding="utf-8") as f: cr = csv.reader(f) - header = [j.lower() for j in next(cr)] + header = [j for j in next(cr)] if header != db_column_names: errmap = dict( - (k, v) for k, v in zip(header, db_column_names) if k != v + (k, v) for k, v in zip(header, db_column_names) #if k != v ) - warnings.warn(f"databáze očekává jiné sloupce: {errmap}") + warnings.warn(f"tabulka {table.name} očekává jiné sloupce: {errmap}") for j, row in enumerate(cr): if len(row) != len(db_column_names): From 5b07e6f0ff66103cce3777d9ed82f7af4a3758cc Mon Sep 17 00:00:00 2001 From: Ondrej Kokes Date: Tue, 10 Jan 2023 13:16:50 +0000 Subject: [PATCH 2/3] revertuj main --- main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 422dd15..d1c975f 100644 --- a/main.py +++ b/main.py @@ -139,10 +139,10 @@ def warninger(message, category, filename, lineno, line=None): for file in files: with open(file, "rt", encoding="utf-8") as f: cr = csv.reader(f) - header = [j for j in next(cr)] + header = [j.lower() for j in next(cr)] if header != db_column_names: errmap = dict( - (k, v) for k, v in zip(header, db_column_names) #if k != v + (k, v) for k, v in zip(header, db_column_names) if k != v ) warnings.warn(f"tabulka {table.name} očekává jiné sloupce: {errmap}") From d6238fb78da57621f24d3938b5a63b58106321fb Mon Sep 17 00:00:00 2001 From: Ondrej Kokes Date: Tue, 10 Jan 2023 13:18:54 +0000 Subject: [PATCH 3/3] inty ico --- data/zakazky/main.py | 8 +++++++- data/zakazky/schema.py | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/data/zakazky/main.py b/data/zakazky/main.py index 34bcb42..e26ef48 100644 --- a/data/zakazky/main.py +++ b/data/zakazky/main.py @@ -117,7 +117,13 @@ def main(outdir: str, partial: bool = False): # cw = csv.writer(fw) cw.writeheader() for row in cr: - cw.writerow({v: row[k] for k, v in props["header"].items()}) + nrow = {v: row[k] for k, v in props["header"].items()} + for k, v in nrow.items(): + if "ico" not in k: + continue + nrow[k] = fix_ico(v) + + cw.writerow(nrow) if __name__ == "__main__": diff --git a/data/zakazky/schema.py b/data/zakazky/schema.py index ac647f5..65fd523 100644 --- a/data/zakazky/schema.py +++ b/data/zakazky/schema.py @@ -292,7 +292,7 @@ Column("id_zadani", Text, nullable=False), Column("cislo_casti_zadani_vz", Text, nullable=True), Column("nazev_casti_vz", Text, nullable=True), - Column("dodavatel_ico", Text, nullable=True, index=True), + Column("dodavatel_ico", Integer, nullable=True, index=True), Column("dodavatel_nazev", Text, nullable=False), Column("dodavatel_postovni_adresa", Text, nullable=True), Column("dodavatel_obec", Text, nullable=False), @@ -311,7 +311,7 @@ Column("druh_formulare", Text, nullable=False), Column("typ_formulare", Text, nullable=False), Column("vz_delena_na_casti", Text, nullable=True), - Column("zadavatel_ico", Text, nullable=True, index=True), + Column("zadavatel_ico", Integer, nullable=True, index=True), Column("limit_vz", Text, nullable=True), Column("datum_odeslani_formulare_na_vvz", Date, nullable=False), Column("datum_uverejneni", Date, nullable=False),