parameters: (load_dict, new_list)
return_statement: return
docstring: This function reads the transaction file, and it also outputs a new file
    regarding
docstring_summary: This function reads the transaction file, and it also outputs a new file
    regarding
docstring_tokens: This function reads the transaction file and it also outputs a new file regarding
function: def read_txn_file(load_dict, new_list):
    """
    This function reads the transaction file, and it also outputs a new file
    regarding
    """
    filename1 = sys.argv[2]
    filename2 = sys.argv[4]
    if os.path.isfile(filename1) is False:
      raise TypeError("Illegal txn file: %s" % (filename1, ))
    elif os.path.isdir(filename2) is True:
      raise TypeError("Illegal output file: %s" % (filename2, ))
  
    fp1 = open(filename1, "r")
    fp2 = open(filename2, "w")
  
    line_num = 0
    max_index = len(new_list)
    for line in fp1:
      if line_num != 0:
        fp2.write("\n")
  
      line = line.strip()
      index = line.find(" ")
      if index == -1:
        raise ValueError("Illegal line @ %d" % (line_num, ))
     
      op = line[:index] 
      out_s = op + " "
  
      if op == "SCAN":
        index2 = line.find(" ", index + 1)
        if index2 == -1: 
          raise ValueError("Illegal scan line @ %d" % (line_num, ))
        key = line[index + 1:index2]
      else:
        key = line[index + 1:]
  
      if op != "INSERT":
        key_index = load_dict.get(key, None)
        if key_index is None:
          raise ValueError("Key %s @ %d does not exist" % (key, line_num))
      
        if key_index >= max_index:
          key_index %= max_index
      
        out_s += new_list[key_index]
      else:
        out_s = line
  
      if op == "SCAN":
        out_s = out_s + line[index2:]
  
      fp2.write(out_s)
      
      line_num += 1
  
    fp1.close()
    fp2.close()
    
    return
function_tokens: def read_txn_file ( load_dict , new_list ) : filename1 = sys . argv [ 2 ] filename2 = sys . argv [ 4 ] if os . path . isfile ( filename1 ) is False : raise TypeError ( "Illegal txn file: %s" % ( filename1 , ) ) elif os . path . isdir ( filename2 ) is True : raise TypeError ( "Illegal output file: %s" % ( filename2 , ) ) fp1 = open ( filename1 , "r" ) fp2 = open ( filename2 , "w" ) line_num = 0 max_index = len ( new_list ) for line in fp1 : if line_num != 0 : fp2 . write ( "\n" ) line = line . strip ( ) index = line . find ( " " ) if index == - 1 : raise ValueError ( "Illegal line @ %d" % ( line_num , ) ) op = line [ : index ] out_s = op + " " if op == "SCAN" : index2 = line . find ( " " , index + 1 ) if index2 == - 1 : raise ValueError ( "Illegal scan line @ %d" % ( line_num , ) ) key = line [ index + 1 : index2 ] else : key = line [ index + 1 : ] if op != "INSERT" : key_index = load_dict . get ( key , None ) if key_index is None : raise ValueError ( "Key %s @ %d does not exist" % ( key , line_num ) ) if key_index >= max_index : key_index %= max_index out_s += new_list [ key_index ] else : out_s = line if op == "SCAN" : out_s = out_s + line [ index2 : ] fp2 . write ( out_s ) line_num += 1 fp1 . close ( ) fp2 . close ( ) return