Untitled

 avatar
unknown
python
2 years ago
864 B
1
Indexable
import pandas as pd
from tenma import TenmaDevice

# Instantiate the TenmaDevice object
tenma = TenmaDevice('COM7')

# Define the mapping of keywords to functions
func_dict = {
    'Turn ON Tenma': tenma.turn_on,
    'Turn OFF Tenma': tenma.turn_off,
    'Set Voltage': tenma.set_voltage,
    'Set Current': tenma.set_current
}

# Read the Excel file
df = pd.read_excel('D:\\New folder\\KDT.xlsx')

for index, row in df.iterrows():
    keyword = row['Keyword']
    arg1 = row['Argument 1']
    arg2 = row['Argument 2']
    
    # Check if the keyword is in the dictionary before calling the corresponding function
    try:
        func_dict[keyword](arg1, arg2)
    except KeyError:
        print(f"Function not found for keyword: {keyword}")
    except Exception as e:
        print(f"An error occurred while executing {keyword}: {e}")