judge_field.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. import re
  2. def _judge_by_field_name(field, yes_list=[], no_list=[]):
  3. res = False
  4. for word in yes_list:
  5. if word in field.lower():
  6. res = True
  7. for word in no_list:
  8. if word in field.lower():
  9. res = False
  10. return res
  11. def judge_by_field_name(column_name):
  12. map_res = {}
  13. for c in list(column_name):
  14. if _judge_by_field_name(c, ['sn', 'vin', '设备号']):
  15. map_res.update({'设备码': c})
  16. if _judge_by_field_name(c, ['time', '时间']):
  17. map_res.update({'时间': c})
  18. if _judge_by_field_name(c, ['crnt', 'current', '电流']):
  19. map_res.update({'电池包电流': c})
  20. if _judge_by_field_name(c, ['volt', 'voltage', '电压'], ['cell', '单体']):
  21. map_res.update({'电池包电压': c})
  22. if _judge_by_field_name(c, ['soc'], ['cell', '单体']):
  23. map_res.update({'电池包soc': c})
  24. if _judge_by_field_name(c, ['soh'], ['cell', '单体']):
  25. map_res.update({'电池包soh': c})
  26. if _judge_by_field_name(c, ['cellvolt', 'cellvoltage', 'cell_voltage','cell_volt', '单体电压']):
  27. map_res.update({'单体电压列表': c})
  28. if _judge_by_field_name(c, ['celltemp', 'celltemperature', 'cell_temp','cell_temperature','单体温度']):
  29. map_res.update({'单体温度列表': c})
  30. if _judge_by_field_name(c, ['电阻', '绝缘电阻', 'resis', 'insula', 'rss']):
  31. map_res.update({'绝缘电阻': c})
  32. return map_res