ArtesiaWater / hydropandas

Module for loading observation data into custom DataFrames
https://hydropandas.readthedocs.io
MIT License
52 stars 11 forks source link

Cannot read BRO uitgiftedocument #195

Closed martinvonk closed 6 months ago

martinvonk commented 6 months ago

I was trying to read a .xml file downloaded from the bro bronhouderportaal. The file is a dispatchDocument and it cannot be read currently by the hydropandas.read_bronhouderportaal_bro() method.

The code fails on

File hydropandas/io/bronhouderportaal_bro.py:88, in get_obs_list_from_dir(dirname, ObsClass, full_meta)
     80 tree = xml.etree.ElementTree.parse(path_xml)
     81 # get number of tubes from XML file
     82 ntubes_from_tree = int(
     83     tree.find(
     84         "isgmw:sourceDocument//"
     85         "isgmw:GMW_Construction//"
     86         "isgmw:numberOfMonitoringTubes",
     87         ns,
---> 88     ).text
     89 )
     90 all_tube_nrs = get_tube_nrs_from_xml(tree, ns)
     91 if len(all_tube_nrs) != ntubes_from_tree:

AttributeError: 'NoneType' object has no attribute 'text'

The file: GMW000000068280.zip has another structure than the current tests / notebooks in HydroPandas because it is an uitgiftedocument (dsgmw?) and not an innamedocument (isgmw?).

I am not too familiar with the BRO data structure. But we should either raise an error if the data format is not known or add support for reading BRO output. Can you help on this issue @HMEUW because you wrote the original bronhouderportaal_bro methods and probably know more about the data structure.

martinvonk commented 6 months ago

Sorry, my entire premise was wrong that bronhouderportaal_bro should be able to read uitgifte while it is intended for inname documents. I want the same as #105 so I'll close this issue as duplicate.