code: def file2iter(filename, encoding='utf-8', comment_prefix="#",
                skip_empty_line=True):
      
      ret = list()
      visited = set()
      with codecs.open(filename, encoding=encoding) as f:
          for line in f:
              line = line.strip()
              # skip empty line
              if skip_empty_line and len(line) == 0:
                  continue
  
              # skip comment line
              if comment_prefix and line.startswith(comment_prefix):
                  continue
  
              yield line
docs: json stream parsing or line parsing