oemof / DHNx

District heating system optimisation and simulation models
MIT License
27 stars 12 forks source link

Editing input data in PyCharm causes error #26

Open jakob-wo opened 4 years ago

jakob-wo commented 4 years ago

I am trying out the _import_exportplot example and noticed the following error (or rather a bug):

To change to position of a consumer I opened _data_csvinput/consumers.csv in PyCharm. In the editor I changed from Text mode (plain editor) to Table Editor (PyCharm gadget to visualise csv as table). When I edit the values in Table Editor mode the csv file changes from

id,lat,lon,node_type 0,51.3470,12.3894,consumer 1,51.3390,12.3880,consumer

to

id,lat,lon,node_type 0,51.3470,12.3894,consumer 1,51.3390,12.3880,consumer ,,, ,,, ,,,

For some reason PyCharm adds empty rows. That causes the following error when executing the example:

  File "import_export_plot.py", line 8, in <module>
    thermal_network.from_csv_folder('data_csv_input')
  File "c:\users\jakob-wo\dhnx\dhnx\network.py", line 85, in from_csv_folder
    self = importer.load()
  File "c:\users\jakob-wo\dhnx\dhnx\input_output.py", line 111, in load
    self.thermal_network.is_consistent()
  File "c:\users\jakob-wo\dhnx\dhnx\network.py", line 182, in is_consistent
    raise ValueError(f"Node {data['to_node']} not defined.")
ValueError: Node consumers-0 not defined.
jakob-wo commented 4 years ago

Well, PyCharm seems to be aware of that problem. They even show a warning in the editor.

Using the table editor might change the format of the CSV file.

jnnr commented 4 years ago

I see. The error message does not really point to the problem. We could add another check of the input data: Assert that id does not contain nans.