main.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import CBMSBatInterShort
  2. import log
  3. #coding=utf-8
  4. import datetime
  5. import pandas as pd
  6. from LIB.BACKEND import DBManager
  7. from sqlalchemy import create_engine
  8. import datetime
  9. import os
  10. dbManager = DBManager.DBManager()
  11. if __name__ == "__main__":
  12. filepath=r'D:\00WorkSpace\01Python\data_analyze_platform\USER\03hezhong\98Download'
  13. files=os.listdir(filepath)
  14. # now_time=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
  15. # now_time=datetime.datetime.strptime(now_time,'%Y-%m-%d %H:%M:%S')
  16. # start_time=now_time-datetime.timedelta(days=30)
  17. # end_time=str(now_time)
  18. # start_time=str(start_time)
  19. #log信息配置
  20. mylog=log.Mylog('log.txt','error')
  21. mylog.logcfg()
  22. for filename in files:
  23. try:
  24. # filename=files[7]
  25. sn=filename[7:-5]
  26. print(sn)
  27. celltype=100
  28. df_volt = pd.read_excel(filepath+'\\'+filename,sheet_name='单体电池电压数据')
  29. df_temp = pd.read_excel(filepath+'\\'+filename,sheet_name='单体电池温度数据')
  30. df_bms = pd.read_excel(filepath+'\\'+filename,sheet_name='整车数据')
  31. df_volt.columns=df_volt.loc[0].astype('str')
  32. df_temp.columns=df_temp.loc[0].astype('str')
  33. df_volt=df_volt.drop(0,axis=0)
  34. df_temp=df_temp.drop(0,axis=0)
  35. df_volt=df_volt.reset_index(drop=True)
  36. df_temp=df_temp.reset_index(drop=True)
  37. df_accum=pd.DataFrame()
  38. # df_volt.to_excel(r'D:\00WorkSpace\01Python\data_analyze_platform\USER\03hezhong\99Result\\'+'CBMS_v_'+sn+'.xlsx')
  39. # df_temp.to_excel(r'D:\00WorkSpace\01Python\data_analyze_platform\USER\03hezhong\99Result\\'+'CBMS_t_'+sn+'.xlsx')
  40. # print(df_volt['1.0'])
  41. BatInterShort=CBMSBatInterShort.BatInterShort(sn,celltype,df_bms,df_volt,df_temp,df_accum)
  42. df_res=BatInterShort.intershort()
  43. df_res.to_excel(r'D:\00WorkSpace\01Python\data_analyze_platform\USER\03hezhong\99Result\\'+'CBMS_InterShort_'+sn+'.xlsx')
  44. print(sn,'done!!!')
  45. except IndexError as e:
  46. print(repr(e))
  47. mylog.logopt(sn,e)
  48. pass