12345678910111213141516171819202122232425262728293031323334 |
- import re
- def _judge_by_field_name(field, yes_list=[], no_list=[]):
- res = False
- for word in yes_list:
- if word in field.lower():
- res = True
- for word in no_list:
- if word in field.lower():
- res = False
- return res
- def judge_by_field_name(column_name):
- map_res = {}
- for c in list(column_name):
- if _judge_by_field_name(c, ['sn', 'vin', '设备号']):
- map_res.update({'设备码': c})
- if _judge_by_field_name(c, ['time', '时间']):
- map_res.update({'时间': c})
- if _judge_by_field_name(c, ['crnt', 'current', '电流']):
- map_res.update({'电池包电流': c})
- if _judge_by_field_name(c, ['volt', 'voltage', '电压'], ['cell', '单体']):
- map_res.update({'电池包电压': c})
- if _judge_by_field_name(c, ['soc'], ['cell', '单体']):
- map_res.update({'电池包soc': c})
- if _judge_by_field_name(c, ['soh'], ['cell', '单体']):
- map_res.update({'电池包soh': c})
- if _judge_by_field_name(c, ['cellvolt', 'cellvoltage', 'cell_voltage','cell_volt', '单体电压']):
- map_res.update({'单体电压列表': c})
- if _judge_by_field_name(c, ['celltemp', 'celltemperature', 'cell_temp','cell_temperature','单体温度']):
- map_res.update({'单体温度列表': c})
- if _judge_by_field_name(c, ['电阻', '绝缘电阻', 'resis', 'insula', 'rss']):
- map_res.update({'绝缘电阻': c})
- return map_res
-
|