main.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import CBMSBatChrg
  2. import log
  3. #coding=utf-8
  4. import datetime
  5. import pandas as pd
  6. from LIB.BACKEND import DBManager, Log
  7. from sqlalchemy import create_engine
  8. import time, 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[0]
  25. print(filename)
  26. sn=filename[0:23]
  27. celltype=100
  28. start_time='2021-04-01 19:12:26'
  29. end_time='2021-09-02 19:12:26'
  30. df_volt = pd.read_excel(filepath+'\\'+filename,sheet_name='单体电池电压数据')
  31. df_temp = pd.read_excel(filepath+'\\'+filename,sheet_name='单体电池温度数据')
  32. df_bms = pd.read_excel(filepath+'\\'+filename,sheet_name='整车数据')
  33. df_volt.columns=df_volt.loc[0].astype('str')
  34. df_temp.columns=df_temp.loc[0].astype('str')
  35. df_volt=df_volt.drop(0,axis=0)
  36. df_temp=df_temp.drop(0,axis=0)
  37. df_volt=df_volt.reset_index(drop=True)
  38. df_temp=df_temp.reset_index(drop=True)
  39. df_accum=pd.DataFrame()
  40. # df_volt.to_excel(r'D:\00WorkSpace\01Python\data_analyze_platform\USER\03hezhong\99Result\\'+'CBMS_v_'+sn+'.xlsx')
  41. # df_temp.to_excel(r'D:\00WorkSpace\01Python\data_analyze_platform\USER\03hezhong\99Result\\'+'CBMS_t_'+sn+'.xlsx')
  42. # print(df_volt['1.0'])
  43. BatChrg=CBMSBatChrg.BatChrg(sn,celltype,df_bms,df_volt,df_temp,df_accum)
  44. df_res=BatChrg.chrg()
  45. # df_res.to_excel(r'D:\00WorkSpace\01Python\data_analyze_platform\USER\03hezhong\99Result\\'+'CBMS_diag_'+sn+'.xlsx')
  46. print(sn,'done!!!')
  47. except IndexError as e:
  48. print(repr(e))
  49. mylog.logopt(sn,e)
  50. pass