Closed ldemattos closed 7 years ago
Hello @ldemattos !
thanks for your help. If I understood correctly your comtrade record is broken, right? I agree with you that pyContrade should not crash in this case, but return to the user an indication of that. In you solution is this your idea or are you trying to read de broken comtrade? If think that a broken cfg should not be readed.
Best regards,
Hi @miguelmoreto !
My pleasure to help!
I don't know if it is broken or those are optional fields, since the record that I'm analyzing opens correctly on other oscillographic readers. I'm not used IEEE Comtrade standard details. Sorry.
The solution that I have proposed simply check if the missing fields exists, and if TRUE, reads it, or else skip it. It's a very simple solution that do not hinder by no means the reading of files that contains all fields. Nevertheless, it make the program more reliable.
I do agree that a broken cfg should not be opened, however this one is a keeper.
Best regards,
Ok. Can you include some comments in the code about these modifications? After that I will merge your PR. Best regards.
Done! PR merged!
The oscillographic record that I'm trying to read doesn't have some data fields that are currently taken for granted by pycomtrade, hence I get IndexError exception. Those fields are:
on method ReadCFG()
self.rev_year = int(templist[2])
and
self.timemul = float(self.filehandler.readline())
I'm proposing a solution through PR. It's based on a simple check of the templist vector length.