import pandas as pd

df = pd.read_excel(r'C:\Users\wzl\Desktop\中广核104测点\0416部署需要\最终测点配置.xlsx',
                   usecols=['标准化中文', '遥测别名', 'en_name', '场站', '风机号'])

df['场站'] = df['场站'].apply(lambda x: x if x != '富风' else '太古')
df['风机号'] = df['风机号'].apply(lambda x: int(x.split('WTG')))
df['风机号'] = df.apply(lambda x: int(x.split('WTG')))

# data_dict = dict()
#
# for _, data in df.iterrows():
#     cn_name = data['标准化中文']
#     bie_ming = data['遥测别名']
#     en_name = data['en_name']
#     changzhan = data['场站'] if data['场站'] != '富风' else '太古'
#     wind_no = int(data['风机号'].split('WTG')) if changzhan != '坡底' else data['风机号'].replace('WTG', 'F')

#     if changzhan in data_dict.keys():
#
#         if wind_no in data_dict[changzhan].keys():
#             data_dict[changzhan][wind_no].append((bie_ming, cn_name, en_name))
#         else:
#             data_dict[changzhan][wind_no] = [(bie_ming, cn_name, en_name)]
#     else:
#         data_dict[changzhan] = {wind_no: [(bie_ming, cn_name, en_name)]}
#
# result = dict()
# result_list = list()
# shunxuhao = 0
# for k, v in data_dict.items():
#     result_dict = dict()
#     result_dict['wind_factory'] = dict()
#     result_dict['wind_factory']['cn_name'] = k
#     result_dict['wind_factory']['wind_factory_no'] = ''
#     wind_turbine_list = list()
#     for k1, v1 in v.items():
#         wind_turbine_dict = dict()
#         wind_turbine_dict['wind_turbine_number'] = k1
#         wind_turbine_dict['measurepoints'] = list()
#         for v2 in v1:
#             point_dict = dict()
#             point_dict['point'] = dict()
#             point_dict['point']['shunxuhao'] = shunxuhao
#             shunxuhao = shunxuhao + 1
#             point_dict['point']['yc_name'] = v2[0]
#             point_dict['point']['standerd_cn_name'] = v2[1]
#             point_dict['point']['standerd_en_name'] = v2[2]
#             wind_turbine_dict['measurepoints'].append(point_dict)
#
#         wind_turbine_list.append(wind_turbine_dict)
#     result_dict['wind_factory']['wind_turbine'] = wind_turbine_list
#     result_list.append(result_dict)
# result['wind_factories'] = result_list
#
# yaml_str = yaml.dump(result, allow_unicode=True, sort_keys=False)
# with open('mesurepoint.yaml', 'w', encoding='utf8') as f:
#     f.write(yaml_str)
