Description of the issue
When using Mastr().download(bulk_cleansing=True), I expect all catalog category values to be translated from the integer in the XML to the corresponding string in Katalogkategorien.xml. This doesn't work corretly for some columns:
Netze.xml: Marktgebiet, Bundesland, Sparte
EinheitenWind.xml: Hersteller
Marktakteure.xml: Rechtsform, Registergericht
These are the ones I identified right now based on some heuristics. Maybe there are more that could be found from the values (cf. solution idea 3 below
Steps to Reproduce
- Run
Mastr().download(bulk_cleansing=True)
- Query e.g.
select distinct Sparte from Netze;. It results in [20, 21], while the desired result is ["Strom", "Gas"].
Ideas of solution
- Ask BNetzA to fix their XSDs so that all catalog category columns are properly marked as
<xs:restriction base="xs:short"> (short can also be int or byte)
- In open-mastr, check the name of columns and compare them with the category names from
Katalogkategorien.xml. If a column name has a match in the category names, treat the column as a category column. The matching cannot be made super strict because the category names sometimes have spelling errors ( Solaranlaege Anlagentyp) and the matching is often only rough e.g. column TechnologieFlugwindenergieanlagefromEinheitenWind.xmlbelongs to categoryTechnologie (Flugwind)`
- We could also try to determine if it's a category from the value that we find in a column. If we only find integers (or comma-separated lists of integers), and many integers occur multiple times, then it's likely that it's a category column. The problem with this approach is that we want to get the table definitions from the XSDs, not the values in the XML files. It would complicate the current approach. And it's also a bit annoying to code.
Context and Environment
- Version used: Unreleased 73d1a3d
- Operating system: Doesn't matter
- Environment setup and (python) version: Doesn't matter
- MaStR version: 20260715
Workflow checklist
Description of the issue
When using
Mastr().download(bulk_cleansing=True), I expect all catalog category values to be translated from the integer in the XML to the corresponding string inKatalogkategorien.xml. This doesn't work corretly for some columns:Netze.xml:Marktgebiet,Bundesland,SparteEinheitenWind.xml:HerstellerMarktakteure.xml:Rechtsform,RegistergerichtThese are the ones I identified right now based on some heuristics. Maybe there are more that could be found from the values (cf. solution idea 3 below
Steps to Reproduce
Mastr().download(bulk_cleansing=True)select distinct Sparte from Netze;. It results in[20, 21], while the desired result is["Strom", "Gas"].Ideas of solution
<xs:restriction base="xs:short">(short can also be int or byte)Katalogkategorien.xml. If a column name has a match in the category names, treat the column as a category column. The matching cannot be made super strict because the category names sometimes have spelling errors ( Solaranlaege Anlagentyp) and the matching is often only rough e.g. columnTechnologieFlugwindenergieanlagefromEinheitenWind.xmlbelongs to categoryTechnologie (Flugwind)`Context and Environment
Workflow checklist