i made the below program to read the required performence metrics from the previous output log file.
previous Output log file present in the 'output_log_path' is given below for your reference,
ac_gain: MAX(mag(v(vout)))=(73.26dB,0°) FROM 1 TO 1e+08
value3db: ac_gain/sqrt(2)=(70.2497dB,0°)
bw: mag(v(vout))=value3db AT 5393.57
gbw: frequency=(148.659dB,0°) at 2.70988e+07
unity_gain_frequency: frequency=(146.429dB,0°) at 2.09633e+07
gain_cross_over_angle: v(vout)=(-0.00012603dB,45.2644°) at 2.09633e+07

Now i need you to modify the below given existing code to read the new performance metrics values of 'gain', 'bw', 'ugf', 'pm' from the below given output lines present in the present 'output_log_path'.
gain: v(vout)/v(vin1)=(75.4048dB,179.93 ) at 10
ac_gain: MAX(mag(v(vout)/v(vin1)))=(75.4048dB,0 ) FROM 10 TO 1e+08
value3db: ac_gain/sqrt(2)=(72.3945dB,0 )
bw: mag(v(vout)/v(vin1))=value3db AT 8241.33
ugf=1.34366e+07 FROM 10 TO 1.34366e+07
pm: v(vout)/v(vin1)=(0.000432435dB,-52.7425 ) at 1.34366e+07

From the performance metrics 'gain', i need to read the value '75.4048',
From the performance metrics 'bw', i need to read the value '8241.33' (the output result may be 1.34366e+03 in some cases, so we need to adapt multiplication factor also to read the value if exista 'e+'),
From the performance metrics 'ugf', i need to read the value '1.34366e+07'
From the performance metrics 'pm', i need to read the value '-52.7425' (it may be positive or negative, and at the end of the result'-52.7425' we have degree unit but unfortunately the log file is encoded in utf-8 encoding format so the degree symbol is not showing in the file, any way i donot need to read its unit i need only the value(poisitive or negative values alone, unit is not needed).
after extracting the pm values, i need to include the computation as 'performance_metrics[pm] = pm + 180 if pm < 0 else pm'

after extracting all the fout required performance metrics 'gain', 'bw', 'ugf', 'pm' we need to return the performance metrics from the function 'simulate_netlist'

Existing code:

# Define the output specifications
Performance_spec = ['gain', 'bw', 'ugf', 'pm']

# Define the paths
ltspice_path = r'C:\Program Files\ADI\LTspice\LTspice.exe'
netlist_path = r'D:\\OPAMP CIRCUITS\\RLGNN_LTSpice\\Netlist_Run_OTA.cir'
output_log_path = r'D:\\OPAMP CIRCUITS\\RLGNN_LTSpice\\Netlist_Run_OTAtemp_netlist.log'


class CircuitSimulator:
    def __init__(self):   
   
    def run_simulation(self, input_parameters):
        try:
            # Update netlist with raw_data
            temp_netlist_path = self.update_netlist(netlist_path, input_parameters)
            
            # Simulate updated netlist in LTSpice simulator
            performance_metrics = self.simulate_netlist(temp_netlist_path, output_log_path, Performance_spec)
        
            return performance_metrics, temp_netlist_path
        
        except Exception as e:
            print(f"Error running simulation: {e}")
            return None 

    # Update netlist with raw_data
    def update_netlist(netlist_path, input_parameters):
        # Update AC analysis netlist
        with open(netlist_path, 'r', encoding='utf-16 LE') as file:
            netlist = file.readlines()

        for i, line in enumerate(netlist):
            for variable, value in dataset.items():
                if '.param {}='.format(variable) in line:
                    param_line = line.strip().split('=')
                    new_line = '{}={}\n'.format(param_line[0], value)
                    netlist[i] = new_line
                    break

        temp_netlist_path = r'D:\\OPAMP CIRCUITS\\RLGNN_LTSpice\\Netlist_Run_OTAtemp_netlist.cir'
        with open(temp_netlist_path, 'w', encoding='utf-16 LE') as file:
            for line in netlist:
                file.write(line)                

        return temp_netlist_path
    
    
    def simulate_netlist(temp_netlist_path, output_log_path, Performance_spec):
        subprocess.run([ltspice_path, '-b', temp_netlist_path])
        performance_metrics = {output_variable: None for output_variable in Performance_spec}

        with open(output_log_path, 'r', encoding='utf-8') as file:
            for line in file:
                line = line.strip()
                for output_parameters in Performance_spec:
                    if output_parameters in line:
                        try:
                            if output_parameters == 'ac_gain':
                                match = re.search(r'MAX\(mag\(v\(vout\)\)\)=\(([\d.]+)dB', line)
                                if match:
                                    value = float(match.group(1))
                                    performance_metrics[output_parameters] = f"{value}dB"
                            elif output_parameters == 'value3db':
                                match = re.search(r'ac_gain/sqrt\(2\)=\(([\d.]+)dB', line)
                                if match:
                                    value = float(match.group(1))
                                    performance_metrics[output_parameters] = f"{value}dB"
                            elif output_parameters == 'bw':
                                match = re.search(r'mag\(v\(vout\)\)=value3db AT ([\d.]+)', line)
                                if match:
                                    value = float(match.group(1))
                                    performance_metrics[output_parameters] = value
                            elif output_parameters == 'gbw':
                                match = re.search(r'frequency=\([\d.]+dB,0°\) at ([\d.e+]+)', line)
                                if match:
                                    value = float(match.group(1))
                                    performance_metrics[output_parameters] = value
                            elif output_parameters == 'unity_gain_frequency':
                                match = re.search(r'frequency=\([\d.]+dB,0°\) at ([\d.e+]+)', line)
                                if match:
                                    value = float(match.group(1))
                                    performance_metrics[output_parameters] = value
                            elif output_parameters == 'gain_cross_over_angle':
                                match = re.search(r'v\(vout\)=\([\d.e-]+dB,([\d.]+)°\) at ([\d.e+]+)', line)
                                if match:
                                    value = float(match.group(1))
                                    performance_metrics[output_parameters] = f"{value}°"
                        except (ValueError, IndexError):
                            performance_metrics[output_parameters] = None    

        return performance_metrics