diff --git a/src/icartt/dataset.py b/src/icartt/dataset.py index afac9fde663f12c39599cb2f62f0614db5836183..7167b0cb7861876c31c1319de0943d648b10a76a 100644 --- a/src/icartt/dataset.py +++ b/src/icartt/dataset.py @@ -214,10 +214,14 @@ class KeywordComment: class StandardNormalComments(collections.UserList): @property def nlines(self): - n = 1 # shortnames line, and keywords might be multiline... - n += len(self.freeform) - n += sum(len(k.data[0].split("\n")) or 1 for k in self.keywords.values()) - # was: len(self.freeform) + 1 + sum([len(k.data) for k in self.keywords.values()]) + """calculates the number of lines in the normal comments section""" + n = 1 # shortnames line + n += len(self.freeform) # freeform comment + for k in self.keywords.values(): + try: + n += len(k.data[0].split("\n")) # and keywords might be multiline... + except IndexError: # ok we have no list, + n += 1 # just add 1 return n @property