FireDynamics / fdsreader

Python reader for FDS data
GNU General Public License v3.0
44 stars 18 forks source link

Problem with DEVC #41

Closed Silvio-Re closed 2 years ago

Silvio-Re commented 2 years ago

Hello,

The console output this error :

ERROR:root:"Module devc: 'complicated'\nThe error can be safely ignored if not requiring the devc module. However, please consider to submit an issue on Github including the error message, the stack trace and your FDS input-file so we can reproduce the error and fix it as soon as possible!"
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-packages\fdsreader\utils\misc.py", line 12, in wrapped
    return f(*args, **kwargs)
  File "C:\ProgramData\Anaconda3\lib\site-packages\fdsreader\simulation.py", line 930, in _load_DEVC_data
    devc = self.devices[names[k]]
KeyError: 'complicated'

Maybe this is a problem due to the fact that my DEVC name contain comas and maybe this little modification to simulation.py in the function _load_DEVC_data could solve it (split by ", instead of ,):

line 927: names = [name.replace('"', '').replace('\n', '').strip() for name in infile.readline().split(',')] -> names = [name.replace('"', '').replace('\n', '').strip() for name in infile.readline().split('",')]

devc_name_string = r'"devc1","complicated, but allowed devc name","devc3"'
names = [name.replace('"', '').replace('\n', '').strip() for name in devc_name_string.split(',')]
names_2 = [name.replace('"', '').replace('\n', '').strip() for name in devc_name_string.split('",')]
names
['devc1', 'complicated', 'but allowed devc name', 'devc3']
names_2
['devc1', 'complicated, but allowed devc name', 'devc3']

This is fully untested in the real code as I do not use fdsreader to read DEVC for now.

Thank you, Silvio

JanVogelsang commented 2 years ago

Fixed in 3c393da

Thanks a lot for submitting this bug report and also investigating the bug yourself. I checked the fds source code on the output format again to ensure your fix will actually work in every possible scenario and could confirm that your suggestion is the way to go. However for the bugfix I actually used split(',"') instead of split('",'), as there are no quotation marks around the first column name (time).