docs: def read(file, system, header=True):
      """Read a dm format file and elem_add to system"""
      retval = True
      fid = open(file, 'r')
      sep = re.compile(r'\s*,\s*')
      comment = re.compile(r'^#\s*')
      equal = re.compile(r'\s*=\s*')
      math = re.compile(r'[*/+-]')
      double = re.compile(r'[+-]? *(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?')
  
      # parse data
      while True:
          line = fid.readline()
          if not line:
              break
          line = line.replace('\n', '')
          line = line.strip()
          if not line:
              continue
          if comment.search(line):
              continue
          # span multiple line
          while line.endswith(',') or line.endswith(';'):
              newline = fid.readline()
              line = line.replace('\n', '')
              newline = newline.strip()
              if not newline:
                  continue
              if comment.search(newline):
                  continue
              line += ' ' + newline
          data = sep.split(line)
          device = data.pop(0)
          device = device.strip()
          if device == 'ALTER':
              alter(data, system)
              continue
          if device == 'INCLUDE':
              logger.debug('Parsing include file <{}>'.format(data[0]))
              newpath = data[0]
              if not os.path.isfile(newpath):
                  newpath = os.path.join(system.files.path, data[0])
                  if not os.path.isfile(newpath):
                      raise FileNotFoundError(
                          'Unable to locate file in {}'.format(newpath))
              read(newpath, system, header=False)  # recursive call
              logger.debug('Parsing of include file <{}> completed.'.format(
                  data[0]))
              continue
          kwargs = {}
          for item in data:
              pair = equal.split(item)
              key = pair[0].strip()
              value = pair[1].strip()
              if value.startswith('"'):
                  value = value[1:-1]
              elif value.startswith('['):
                  array = value[1:-1].split(';')
                  if math.search(value):  # execute simple operations
                      value = list(map(lambda x: eval(x), array))
                  else:
                      value = list(map(lambda x: float(x), array))
              elif double.search(value):
                  if math.search(value):  # execute simple operations
                      value = eval(value)
                  else:
                      value = float(value)
              elif value == 'True':
                  value = True
              elif value == 'False':
                  value = False
              else:
                  value = int(value)
              kwargs[key] = value
          index = kwargs.pop('idx', None)
          namex = kwargs.pop('name', None)
          try:
              system.__dict__[device].elem_add(idx=index, name=namex, **kwargs)
          except KeyError:
              logger.error(
                  'Error adding device {:s} to powersystem object.'.format(
                      device))
              logger.debug(
                  'Make sure you have added the jit models in __init__.py'
              )
  
      fid.close()
      return retval