{ "cells": [ { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "import oss2\n", "from itertools import islice\n", "import pandas as pd\n", "columns = [\"id\",\"VIN\",\"VehModel\",\"VehState\",\"Time\",\"CellVoltage\",\"PackVoltage\",'CellMaxVolNum',\"CellMinVolNum\",'CellTemp','CellMaxTempNum','CellMinTempNum','PackCrnt','VehRmnRng','VehOdo','FltCode',\n", "'FltLvl','VehSpd','PedalAngle','PackSoc','MotorPwr','EnmTemp','InsulationRss','ChrgSta','GPS_lon','GPS_lat','GPS_alt',\n", " 'PowerAlreadyTime','BMSSta','ACSta','OncCmState','HVILSta','OfcAccumTime','OncAccumTime','BmsOncChgCp','BmsOfcPileOutputVol','BmsOfcPileOutputCur','BmsOfcCc','BmsOfcAllowed',\n", " 'OncOutCurrent','OncOutVoltage','OfcStationMaxOutVolt','OfcStationMinOutVolt','OfcStationMaxOutCrnt','OfcStationMinOutCrnt','BmsOfcgVoltageRequest','BmsOfcType','BmsOfcCurrentRequest',\n", " 'BmsOncChgRequest','BmsRequestOutputCurrent','BmsRequestOutputVoltage','BmsOncCc','BmsS2State','HvUpState','HvDownState','CellMaxVol','CellMinVol','CellMaxTemp','CellMinTemp','Tripmeter',\n", " 'VehAccX','VehAccY','StringAngle','PTCSta','PTCPwr','PosRlySta','NegRlySta','OfcPreRlySta','OfcRlySta','OfcPosChrgerTemp','OfcNegChrgerTemp','OncPosChrgerTemp','OncNegChrgerTemp',\n", " 'InstPwrCmsmtion','AvgPwrCmsmtion','SubPwrCmsmtion','BmsCellVoltDiff','DriveMode','BmsBatTempDiff','BmsClmThermalSts','BmsBatteryTotalCapacity','BmsBatteryAvaiCapacity',\n", " 'BmsOncChgCpConn','CellVoltRecTime','CellVoltTotalCount','CellVoltFrameNo','CellVoltFrameCount','CellTempTotalCount','SN','BatteryModel']\n", "auth = oss2.Auth('LTAI4FyoDnXMjqd78rdRDFHN', 'sdFl6vjM9l2rvWiUTzuFQb2xqjUoY5')\n", "bucket = oss2.Bucket(auth, \"https://oss-cn-hangzhou.aliyuncs.com\", 'ff-hezhong')\n", "df_data = pd.DataFrame(columns = columns) \n", "for b in oss2.ObjectIterator(bucket,'alg/LUZAGAAA1MA038075/202202251410/'):\n", " bucket.get_object_to_file(b.key, 'test.txt')\n", " df = pd.read_csv('test.txt', names=columns, sep=' ')\n", " df_data = pd.concat([df_data,df])\n", "df_data = df_data.reset_index(drop=True)\n" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "b'{\"sn\":\"0CZPE007DN0111B4K0000084\",\"key\":\"0CZPE007DN0111B4K0000084_202202271605\",\"module_model_code\":\"J9\",\"pack_series_parallerl\":\"2P96S\",\"cell_battery_type\":\"E\",\"cell_dict_shape\":\"3\",\"pack_model_code\":\"2101TAB\",\"module_manufactory\":\"\\xe5\\x8d\\x8e\\xe9\\xbc\\x8e\\xe5\\x9b\\xbd\\xe8\\x81\\x94\\xe5\\x8a\\xa8\\xe5\\x8a\\x9b\\xe7\\x94\\xb5\\xe6\\xb1\\xa0\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\",\"pack_capacity\":\"122\",\"cell_manufactory\":\"\\xe5\\x8d\\x8e\\xe9\\xbc\\x8e\\xe5\\x9b\\xbd\\xe8\\x81\\x94\\xe5\\x8a\\xa8\\xe5\\x8a\\x9b\\xe7\\x94\\xb5\\xe6\\xb1\\xa0\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\"}'\n", "0\n", "b'{\"sn\":\"09SPE005FA0111B8L0000059\",\"key\":\"09SPE005FA0111B8L0000059_202202271605\",\"module_model_code\":\"MODULE_2.64kWh_177Ah_1P4S\",\"pack_series_parallerl\":\"1P104S\",\"cell_battery_type\":\"E\",\"cell_dict_shape\":\"1\",\"pack_model_code\":\"2101TW\",\"module_manufactory\":\"\\xe5\\xae\\x81\\xe5\\xbe\\xb7\\xe6\\x97\\xb6\\xe4\\xbb\\xa3\\xe6\\x96\\xb0\\xe8\\x83\\xbd\\xe6\\xba\\x90\\xe7\\xa7\\x91\\xe6\\x8a\\x80\\xe8\\x82\\xa1\\xe4\\xbb\\xbd\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\",\"pack_capacity\":\"174\",\"cell_manufactory\":\"\\xe5\\xae\\x81\\xe5\\xbe\\xb7\\xe6\\x97\\xb6\\xe4\\xbb\\xa3\\xe6\\x96\\xb0\\xe8\\x83\\xbd\\xe6\\xba\\x90\\xe7\\xa7\\x91\\xe6\\x8a\\x80\\xe8\\x82\\xa1\\xe4\\xbb\\xbd\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\"}'\n", "0\n", "b'{\"sn\":\"001PB047000001A8D0100014\",\"key\":\"001PB047000001A8D0100014_202202271605\",\"module_model_code\":\"CB350\",\"pack_series_parallerl\":\"1P112S\",\"cell_battery_type\":\"B\",\"cell_dict_shape\":\"1\",\"pack_model_code\":\"2101TS\",\"module_manufactory\":\"\\xe5\\xae\\x81\\xe5\\xbe\\xb7\\xe6\\x97\\xb6\\xe4\\xbb\\xa3\\xe6\\x96\\xb0\\xe8\\x83\\xbd\\xe6\\xba\\x90\\xe7\\xa7\\x91\\xe6\\x8a\\x80\\xe8\\x82\\xa1\\xe4\\xbb\\xbd\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\",\"pack_capacity\":\"87\",\"cell_manufactory\":\"\\xe5\\xae\\x81\\xe5\\xbe\\xb7\\xe6\\x97\\xb6\\xe4\\xbb\\xa3\\xe6\\x96\\xb0\\xe8\\x83\\xbd\\xe6\\xba\\x90\\xe7\\xa7\\x91\\xe6\\x8a\\x80\\xe8\\x82\\xa1\\xe4\\xbb\\xbd\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\"}'\n", "0\n", "b'{\"sn\":\"0CZPE007DN0111B990000050\",\"key\":\"0CZPE007DN0111B990000050_202202271605\",\"module_model_code\":\"J9\",\"pack_series_parallerl\":\"2P96S\",\"cell_battery_type\":\"E\",\"cell_dict_shape\":\"3\",\"pack_model_code\":\"2101TAB\",\"module_manufactory\":\"\\xe5\\x8d\\x8e\\xe9\\xbc\\x8e\\xe5\\x9b\\xbd\\xe8\\x81\\x94\\xe5\\x8a\\xa8\\xe5\\x8a\\x9b\\xe7\\x94\\xb5\\xe6\\xb1\\xa0\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\",\"pack_capacity\":\"122\",\"cell_manufactory\":\"\\xe5\\x8d\\x8e\\xe9\\xbc\\x8e\\xe5\\x9b\\xbd\\xe8\\x81\\x94\\xe5\\x8a\\xa8\\xe5\\x8a\\x9b\\xe7\\x94\\xb5\\xe6\\xb1\\xa0\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\"}'\n", "0\n", "b'{\"sn\":\"0CZPE007DN0111B800000064\",\"key\":\"0CZPE007DN0111B800000064_202202271605\",\"module_model_code\":\"J9\",\"pack_series_parallerl\":\"2P96S\",\"cell_battery_type\":\"E\",\"cell_dict_shape\":\"3\",\"pack_model_code\":\"2101TAB\",\"module_manufactory\":\"\\xe5\\x8d\\x8e\\xe9\\xbc\\x8e\\xe5\\x9b\\xbd\\xe8\\x81\\x94\\xe5\\x8a\\xa8\\xe5\\x8a\\x9b\\xe7\\x94\\xb5\\xe6\\xb1\\xa0\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\",\"pack_capacity\":\"122\",\"cell_manufactory\":\"\\xe5\\x8d\\x8e\\xe9\\xbc\\x8e\\xe5\\x9b\\xbd\\xe8\\x81\\x94\\xe5\\x8a\\xa8\\xe5\\x8a\\x9b\\xe7\\x94\\xb5\\xe6\\xb1\\xa0\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\"}'\n", "0\n", "b'{\"sn\":\"001PB047000001AA70100148\",\"key\":\"001PB047000001AA70100148_202202271605\",\"module_model_code\":\"CB350\",\"pack_series_parallerl\":\"1P112S\",\"cell_battery_type\":\"B\",\"cell_dict_shape\":\"1\",\"pack_model_code\":\"2101TS\",\"module_manufactory\":\"\\xe5\\xae\\x81\\xe5\\xbe\\xb7\\xe6\\x97\\xb6\\xe4\\xbb\\xa3\\xe6\\x96\\xb0\\xe8\\x83\\xbd\\xe6\\xba\\x90\\xe7\\xa7\\x91\\xe6\\x8a\\x80\\xe8\\x82\\xa1\\xe4\\xbb\\xbd\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\",\"pack_capacity\":\"87\",\"cell_manufactory\":\"\\xe5\\xae\\x81\\xe5\\xbe\\xb7\\xe6\\x97\\xb6\\xe4\\xbb\\xa3\\xe6\\x96\\xb0\\xe8\\x83\\xbd\\xe6\\xba\\x90\\xe7\\xa7\\x91\\xe6\\x8a\\x80\\xe8\\x82\\xa1\\xe4\\xbb\\xbd\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\"}'\n", "0\n", "b'{\"sn\":\"0CZPE007DN0111B8S0000045\",\"key\":\"0CZPE007DN0111B8S0000045_202202271605\",\"module_model_code\":\"J9\",\"pack_series_parallerl\":\"2P96S\",\"cell_battery_type\":\"E\",\"cell_dict_shape\":\"3\",\"pack_model_code\":\"2101TAB\",\"module_manufactory\":\"\\xe5\\x8d\\x8e\\xe9\\xbc\\x8e\\xe5\\x9b\\xbd\\xe8\\x81\\x94\\xe5\\x8a\\xa8\\xe5\\x8a\\x9b\\xe7\\x94\\xb5\\xe6\\xb1\\xa0\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\",\"pack_capacity\":\"122\",\"cell_manufactory\":\"\\xe5\\x8d\\x8e\\xe9\\xbc\\x8e\\xe5\\x9b\\xbd\\xe8\\x81\\x94\\xe5\\x8a\\xa8\\xe5\\x8a\\x9b\\xe7\\x94\\xb5\\xe6\\xb1\\xa0\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\"}'\n", "0\n", "b'{\"sn\":\"09SPE006DA0111A9K0000014\",\"key\":\"09SPE006DA0111A9K0000014_202202271605\",\"module_model_code\":\"MEAFG\",\"pack_series_parallerl\":\"1P96S\",\"cell_battery_type\":\"E\",\"cell_dict_shape\":\"1\",\"pack_model_code\":\"2101TZ\",\"module_manufactory\":\"\\xe6\\xb1\\x9f\\xe8\\x8b\\x8f\\xe6\\x97\\xb6\\xe4\\xbb\\xa3\\xe6\\x96\\xb0\\xe8\\x83\\xbd\\xe6\\xba\\x90\\xe7\\xa7\\x91\\xe6\\x8a\\x80\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\",\"pack_capacity\":\"110\",\"cell_manufactory\":\"\\xe5\\xae\\x81\\xe5\\xbe\\xb7\\xe6\\x97\\xb6\\xe4\\xbb\\xa3\\xe6\\x96\\xb0\\xe8\\x83\\xbd\\xe6\\xba\\x90\\xe7\\xa7\\x91\\xe6\\x8a\\x80\\xe8\\x82\\xa1\\xe4\\xbb\\xbd\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\"}'\n", "0\n", "b'{\"sn\":\"0CZPE007DN0111B8T0000051\",\"key\":\"0CZPE007DN0111B8T0000051_202202271605\",\"module_model_code\":\"J9\",\"pack_series_parallerl\":\"2P96S\",\"cell_battery_type\":\"E\",\"cell_dict_shape\":\"3\",\"pack_model_code\":\"2101TAB\",\"module_manufactory\":\"\\xe5\\x8d\\x8e\\xe9\\xbc\\x8e\\xe5\\x9b\\xbd\\xe8\\x81\\x94\\xe5\\x8a\\xa8\\xe5\\x8a\\x9b\\xe7\\x94\\xb5\\xe6\\xb1\\xa0\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\",\"pack_capacity\":\"122\",\"cell_manufactory\":\"\\xe5\\x8d\\x8e\\xe9\\xbc\\x8e\\xe5\\x9b\\xbd\\xe8\\x81\\x94\\xe5\\x8a\\xa8\\xe5\\x8a\\x9b\\xe7\\x94\\xb5\\xe6\\xb1\\xa0\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\"}'\n", "0\n", "b'{\"sn\":\"0CZPE007DN0111B4K0000084\",\"key\":\"0CZPE007DN0111B4K0000084_202202271606\",\"module_model_code\":\"J9\",\"pack_series_parallerl\":\"2P96S\",\"cell_battery_type\":\"E\",\"cell_dict_shape\":\"3\",\"pack_model_code\":\"2101TAB\",\"module_manufactory\":\"\\xe5\\x8d\\x8e\\xe9\\xbc\\x8e\\xe5\\x9b\\xbd\\xe8\\x81\\x94\\xe5\\x8a\\xa8\\xe5\\x8a\\x9b\\xe7\\x94\\xb5\\xe6\\xb1\\xa0\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\",\"pack_capacity\":\"122\",\"cell_manufactory\":\"\\xe5\\x8d\\x8e\\xe9\\xbc\\x8e\\xe5\\x9b\\xbd\\xe8\\x81\\x94\\xe5\\x8a\\xa8\\xe5\\x8a\\x9b\\xe7\\x94\\xb5\\xe6\\xb1\\xa0\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\"}'\n", "0\n", "b'{\"sn\":\"0CZPE007DN0111B990000050\",\"key\":\"0CZPE007DN0111B990000050_202202271606\",\"module_model_code\":\"J9\",\"pack_series_parallerl\":\"2P96S\",\"cell_battery_type\":\"E\",\"cell_dict_shape\":\"3\",\"pack_model_code\":\"2101TAB\",\"module_manufactory\":\"\\xe5\\x8d\\x8e\\xe9\\xbc\\x8e\\xe5\\x9b\\xbd\\xe8\\x81\\x94\\xe5\\x8a\\xa8\\xe5\\x8a\\x9b\\xe7\\x94\\xb5\\xe6\\xb1\\xa0\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\",\"pack_capacity\":\"122\",\"cell_manufactory\":\"\\xe5\\x8d\\x8e\\xe9\\xbc\\x8e\\xe5\\x9b\\xbd\\xe8\\x81\\x94\\xe5\\x8a\\xa8\\xe5\\x8a\\x9b\\xe7\\x94\\xb5\\xe6\\xb1\\xa0\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\"}'\n", "0\n", "b'{\"sn\":\"0CZPE007DN0111B8S0000045\",\"key\":\"0CZPE007DN0111B8S0000045_202202271606\",\"module_model_code\":\"J9\",\"pack_series_parallerl\":\"2P96S\",\"cell_battery_type\":\"E\",\"cell_dict_shape\":\"3\",\"pack_model_code\":\"2101TAB\",\"module_manufactory\":\"\\xe5\\x8d\\x8e\\xe9\\xbc\\x8e\\xe5\\x9b\\xbd\\xe8\\x81\\x94\\xe5\\x8a\\xa8\\xe5\\x8a\\x9b\\xe7\\x94\\xb5\\xe6\\xb1\\xa0\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\",\"pack_capacity\":\"122\",\"cell_manufactory\":\"\\xe5\\x8d\\x8e\\xe9\\xbc\\x8e\\xe5\\x9b\\xbd\\xe8\\x81\\x94\\xe5\\x8a\\xa8\\xe5\\x8a\\x9b\\xe7\\x94\\xb5\\xe6\\xb1\\xa0\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\"}'\n", "0\n", "b'{\"sn\":\"001PB047000001A8D0100014\",\"key\":\"001PB047000001A8D0100014_202202271606\",\"module_model_code\":\"CB350\",\"pack_series_parallerl\":\"1P112S\",\"cell_battery_type\":\"B\",\"cell_dict_shape\":\"1\",\"pack_model_code\":\"2101TS\",\"module_manufactory\":\"\\xe5\\xae\\x81\\xe5\\xbe\\xb7\\xe6\\x97\\xb6\\xe4\\xbb\\xa3\\xe6\\x96\\xb0\\xe8\\x83\\xbd\\xe6\\xba\\x90\\xe7\\xa7\\x91\\xe6\\x8a\\x80\\xe8\\x82\\xa1\\xe4\\xbb\\xbd\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\",\"pack_capacity\":\"87\",\"cell_manufactory\":\"\\xe5\\xae\\x81\\xe5\\xbe\\xb7\\xe6\\x97\\xb6\\xe4\\xbb\\xa3\\xe6\\x96\\xb0\\xe8\\x83\\xbd\\xe6\\xba\\x90\\xe7\\xa7\\x91\\xe6\\x8a\\x80\\xe8\\x82\\xa1\\xe4\\xbb\\xbd\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\"}'\n", "0\n", "b'{\"sn\":\"0CZPE007DN0111B8T0000051\",\"key\":\"0CZPE007DN0111B8T0000051_202202271606\",\"module_model_code\":\"J9\",\"pack_series_parallerl\":\"2P96S\",\"cell_battery_type\":\"E\",\"cell_dict_shape\":\"3\",\"pack_model_code\":\"2101TAB\",\"module_manufactory\":\"\\xe5\\x8d\\x8e\\xe9\\xbc\\x8e\\xe5\\x9b\\xbd\\xe8\\x81\\x94\\xe5\\x8a\\xa8\\xe5\\x8a\\x9b\\xe7\\x94\\xb5\\xe6\\xb1\\xa0\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\",\"pack_capacity\":\"122\",\"cell_manufactory\":\"\\xe5\\x8d\\x8e\\xe9\\xbc\\x8e\\xe5\\x9b\\xbd\\xe8\\x81\\x94\\xe5\\x8a\\xa8\\xe5\\x8a\\x9b\\xe7\\x94\\xb5\\xe6\\xb1\\xa0\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\"}'\n", "0\n", "b'{\"sn\":\"001PB047000001AA70100148\",\"key\":\"001PB047000001AA70100148_202202271606\",\"module_model_code\":\"CB350\",\"pack_series_parallerl\":\"1P112S\",\"cell_battery_type\":\"B\",\"cell_dict_shape\":\"1\",\"pack_model_code\":\"2101TS\",\"module_manufactory\":\"\\xe5\\xae\\x81\\xe5\\xbe\\xb7\\xe6\\x97\\xb6\\xe4\\xbb\\xa3\\xe6\\x96\\xb0\\xe8\\x83\\xbd\\xe6\\xba\\x90\\xe7\\xa7\\x91\\xe6\\x8a\\x80\\xe8\\x82\\xa1\\xe4\\xbb\\xbd\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\",\"pack_capacity\":\"87\",\"cell_manufactory\":\"\\xe5\\xae\\x81\\xe5\\xbe\\xb7\\xe6\\x97\\xb6\\xe4\\xbb\\xa3\\xe6\\x96\\xb0\\xe8\\x83\\xbd\\xe6\\xba\\x90\\xe7\\xa7\\x91\\xe6\\x8a\\x80\\xe8\\x82\\xa1\\xe4\\xbb\\xbd\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\"}'\n", "0\n", "b'{\"sn\":\"09SPE006DA0111A9K0000014\",\"key\":\"09SPE006DA0111A9K0000014_202202271606\",\"module_model_code\":\"MEAFG\",\"pack_series_parallerl\":\"1P96S\",\"cell_battery_type\":\"E\",\"cell_dict_shape\":\"1\",\"pack_model_code\":\"2101TZ\",\"module_manufactory\":\"\\xe6\\xb1\\x9f\\xe8\\x8b\\x8f\\xe6\\x97\\xb6\\xe4\\xbb\\xa3\\xe6\\x96\\xb0\\xe8\\x83\\xbd\\xe6\\xba\\x90\\xe7\\xa7\\x91\\xe6\\x8a\\x80\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\",\"pack_capacity\":\"110\",\"cell_manufactory\":\"\\xe5\\xae\\x81\\xe5\\xbe\\xb7\\xe6\\x97\\xb6\\xe4\\xbb\\xa3\\xe6\\x96\\xb0\\xe8\\x83\\xbd\\xe6\\xba\\x90\\xe7\\xa7\\x91\\xe6\\x8a\\x80\\xe8\\x82\\xa1\\xe4\\xbb\\xbd\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\"}'\n", "0\n", "b'{\"sn\":\"0CZPE007DN0111B800000064\",\"key\":\"0CZPE007DN0111B800000064_202202271606\",\"module_model_code\":\"J9\",\"pack_series_parallerl\":\"2P96S\",\"cell_battery_type\":\"E\",\"cell_dict_shape\":\"3\",\"pack_model_code\":\"2101TAB\",\"module_manufactory\":\"\\xe5\\x8d\\x8e\\xe9\\xbc\\x8e\\xe5\\x9b\\xbd\\xe8\\x81\\x94\\xe5\\x8a\\xa8\\xe5\\x8a\\x9b\\xe7\\x94\\xb5\\xe6\\xb1\\xa0\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\",\"pack_capacity\":\"122\",\"cell_manufactory\":\"\\xe5\\x8d\\x8e\\xe9\\xbc\\x8e\\xe5\\x9b\\xbd\\xe8\\x81\\x94\\xe5\\x8a\\xa8\\xe5\\x8a\\x9b\\xe7\\x94\\xb5\\xe6\\xb1\\xa0\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\"}'\n", "0\n", "b'{\"sn\":\"09SPE005FA0111B8L0000059\",\"key\":\"09SPE005FA0111B8L0000059_202202271606\",\"module_model_code\":\"MODULE_2.64kWh_177Ah_1P4S\",\"pack_series_parallerl\":\"1P104S\",\"cell_battery_type\":\"E\",\"cell_dict_shape\":\"1\",\"pack_model_code\":\"2101TW\",\"module_manufactory\":\"\\xe5\\xae\\x81\\xe5\\xbe\\xb7\\xe6\\x97\\xb6\\xe4\\xbb\\xa3\\xe6\\x96\\xb0\\xe8\\x83\\xbd\\xe6\\xba\\x90\\xe7\\xa7\\x91\\xe6\\x8a\\x80\\xe8\\x82\\xa1\\xe4\\xbb\\xbd\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\",\"pack_capacity\":\"174\",\"cell_manufactory\":\"\\xe5\\xae\\x81\\xe5\\xbe\\xb7\\xe6\\x97\\xb6\\xe4\\xbb\\xa3\\xe6\\x96\\xb0\\xe8\\x83\\xbd\\xe6\\xba\\x90\\xe7\\xa7\\x91\\xe6\\x8a\\x80\\xe8\\x82\\xa1\\xe4\\xbb\\xbd\\xe6\\x9c\\x89\\xe9\\x99\\x90\\xe5\\x85\\xac\\xe5\\x8f\\xb8\"}'\n", "0\n" ] } ], "source": [ "import ssl\n", "from kafka import KafkaProducer, KafkaConsumer\n", "from kafka.errors import kafka_errors\n", "import traceback\n", "import json\n", "import pdb\n", "import os\n", "import pandas as pd\n", "import oss2\n", "from itertools import islice\n", "import pandas as pd\n", "context = ssl.create_default_context()\n", "context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)\n", "## The new python(2.7.8+) may cannot ignore the hostname check,\n", "## you could set to ssl.CERT_NONE to walk around the problem,\n", "## or you can change the client to confluent-python-demo \n", "\n", "# context.verify_mode = ssl.CERT_NONE\n", "context.verify_mode = ssl.CERT_REQUIRED\n", "topic = 'toAlgSn' # toAlg, toAlgSn\n", "# context.check_hostname = True\n", "context.load_verify_locations(\"ca-cert\")\n", "consumer = KafkaConsumer(topic, bootstrap_servers=['alikafka-pre-cn-8ed2kw57901x-1.alikafka.aliyuncs.com:9093',\n", " 'alikafka-pre-cn-8ed2kw57901x-2.alikafka.aliyuncs.com:9093',\n", " 'alikafka-pre-cn-8ed2kw57901x-3.alikafka.aliyuncs.com:9093'],\n", " sasl_mechanism=\"PLAIN\",\n", " ssl_context=context,\n", " security_protocol='SASL_SSL',\n", " api_version = (2,2),\n", " sasl_plain_username='alikafka_pre-cn-8ed2kw57901x',\n", " sasl_plain_password='hlQsApgUUdUxcWEr1uQoM9BeuF8t8vMF',\n", " consumer_timeout_ms= 100000000, # 如果10秒内kafka中没有可供消费的数据,自动退出\n", " client_id='consumer-python3',\n", " auto_offset_reset='earliest',# 消费kafka中最近的数据,如果设置为earliest则消费最早的数据,不管这些数据是否消费\n", " enable_auto_commit=True, # 自动提交消费者的offset\n", " auto_commit_interval_ms=3000, ## 自动提交消费者offset的时间间隔,\n", "\n", ")\n", "\n", "columns = [\"id\",\"VIN\",\"VehModel\",\"VehState\",\"Time\",\"CellVoltage\",\"PackVoltage\",'CellMaxVolNum',\"CellMinVolNum\",'CellTemp','CellMaxTempNum','CellMinTempNum','PackCrnt','VehRmnRng','VehOdo','FltCode',\n", "'FltLvl','VehSpd','PedalAngle','PackSoc','MotorPwr','EnmTemp','InsulationRss','ChrgSta','GPS_lon','GPS_lat','GPS_alt',\n", " 'PowerAlreadyTime','BMSSta','ACSta','OncCmState','HVILSta','OfcAccumTime','OncAccumTime','BmsOncChgCp','BmsOfcPileOutputVol','BmsOfcPileOutputCur','BmsOfcCc','BmsOfcAllowed',\n", " 'OncOutCurrent','OncOutVoltage','OfcStationMaxOutVolt','OfcStationMinOutVolt','OfcStationMaxOutCrnt','OfcStationMinOutCrnt','BmsOfcgVoltageRequest','BmsOfcType','BmsOfcCurrentRequest',\n", " 'BmsOncChgRequest','BmsRequestOutputCurrent','BmsRequestOutputVoltage','BmsOncCc','BmsS2State','HvUpState','HvDownState','CellMaxVol','CellMinVol','CellMaxTemp','CellMinTemp','Tripmeter',\n", " 'VehAccX','VehAccY','StringAngle','PTCSta','PTCPwr','PosRlySta','NegRlySta','OfcPreRlySta','OfcRlySta','OfcPosChrgerTemp','OfcNegChrgerTemp','OncPosChrgerTemp','OncNegChrgerTemp',\n", " 'InstPwrCmsmtion','AvgPwrCmsmtion','SubPwrCmsmtion','BmsCellVoltDiff','DriveMode','BmsBatTempDiff','BmsClmThermalSts','BmsBatteryTotalCapacity','BmsBatteryAvaiCapacity',\n", " 'BmsOncChgCpConn','CellVoltRecTime','CellVoltTotalCount','CellVoltFrameNo','CellVoltFrameCount','CellTempTotalCount','SN','BatteryModel']\n", "auth = oss2.Auth('LTAI4FyoDnXMjqd78rdRDFHN', 'sdFl6vjM9l2rvWiUTzuFQb2xqjUoY5')\n", "bucket = oss2.Bucket(auth, \"https://oss-cn-hangzhou.aliyuncs.com\", 'ff-hezhong')\n", " \n", "\n", "for message in consumer:\n", " print(message.value)\n", " # 读取vin数据\n", " # df_data = pd.DataFrame(columns = columns) \n", " # for b in oss2.ObjectIterator(bucket,'alg/'+str(message.value,'utf-8').replace(\"_\",\"/\")):\n", " # bucket.get_object_to_file(b.key, 'test.txt')\n", " # df = pd.read_csv('test.txt', names=columns, sep=' ')\n", " # df_data = pd.concat([df_data,df])\n", " # df_data = df_data.reset_index(drop=True)\n", " \n", " # 读取sn数据\n", " df_data = pd.DataFrame(columns = columns) \n", " for b in oss2.ObjectIterator(bucket,'alg/'+str(message.value,'utf-8').replace(\"_\",\"/\")):\n", " bucket.get_object_to_file(b.key, 'test.txt')\n", " df = pd.read_csv('test.txt', names=columns, sep=' ')\n", " df_data = pd.concat([df_data,df])\n", " df_data = df_data.reset_index(drop=True)\n", " print(str(len(df_data)))\n", " \n", " \n", "\n" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'LUZAGAAA5MA009680/202202271606'" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "str(message.value,'utf-8').replace(\"_\",\"/\")" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "df_data['Time'] = pd.to_datetime(df['Time'],unit='ms')" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | id | \n", "VIN | \n", "VehModel | \n", "VehState | \n", "Time | \n", "CellVoltage | \n", "PackVoltage | \n", "CellMaxVolNum | \n", "CellMinVolNum | \n", "CellTemp | \n", "... | \n", "BmsBatteryTotalCapacity | \n", "BmsBatteryAvaiCapacity | \n", "BmsOncChgCpConn | \n", "CellVoltRecTime | \n", "CellVoltTotalCount | \n", "CellVoltFrameNo | \n", "CellVoltFrameCount | \n", "CellTempTotalCount | \n", "SN | \n", "BatteryModel | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "1803242740_LUZAGAAA5MA009680_9223370390905621153 | \n", "LUZAGAAA5MA009680 | \n", "EP12 | \n", "2 | \n", "2022-02-27 08:05:54.654 | \n", "4.084,4.084,4.085,4.085,4.087,4.087,4.088,4.08... | \n", "392.2 | \n", "26 | \n", "84 | \n", "14,15,14,14,14,14,13,13,12,12,12,12,11,12,11,1... | \n", "... | \n", "4.294967e+09 | \n", "4.294967e+09 | \n", "255 | \n", "1641150270000 | \n", "96 | \n", "1 | \n", "96 | \n", "32 | \n", "0CZPE007DN0111B4K0000084 | \n", "NaN | \n", "
1 | \n", "1803242740_LUZAGAAA5MA009680_9223370390905621122 | \n", "LUZAGAAA5MA009680 | \n", "EP12 | \n", "2 | \n", "2022-02-27 08:05:54.685 | \n", "4.061,4.063,4.064,4.064,4.064,4.064,4.065,4.06... | \n", "390.0 | \n", "18 | \n", "84 | \n", "19,20,19,20,18,19,18,19,16,17,17,18,16,16,16,1... | \n", "... | \n", "4.294967e+09 | \n", "4.294967e+09 | \n", "255 | \n", "1641171313000 | \n", "96 | \n", "1 | \n", "96 | \n", "32 | \n", "0CZPE007DN0111B4K0000084 | \n", "NaN | \n", "
2 | \n", "1803242740_LUZAGAAA5MA009680_9223370390905621106 | \n", "LUZAGAAA5MA009680 | \n", "EP12 | \n", "2 | \n", "2022-02-27 08:05:54.701 | \n", "4.084,4.084,4.085,4.085,4.087,4.087,4.088,4.08... | \n", "392.2 | \n", "26 | \n", "84 | \n", "14,15,14,14,14,14,13,13,12,12,12,12,11,12,11,1... | \n", "... | \n", "4.294967e+09 | \n", "4.294967e+09 | \n", "255 | \n", "1641150270000 | \n", "96 | \n", "1 | \n", "96 | \n", "32 | \n", "0CZPE007DN0111B4K0000084 | \n", "NaN | \n", "
3 | \n", "1803242740_LUZAGAAA5MA009680_9223370390905621092 | \n", "LUZAGAAA5MA009680 | \n", "EP12 | \n", "2 | \n", "2022-02-27 08:05:54.715 | \n", "4.061,4.063,4.064,4.064,4.064,4.064,4.065,4.06... | \n", "390.0 | \n", "18 | \n", "84 | \n", "19,20,19,20,18,19,18,19,16,17,17,18,16,16,16,1... | \n", "... | \n", "4.294967e+09 | \n", "4.294967e+09 | \n", "255 | \n", "1641171313000 | \n", "96 | \n", "1 | \n", "96 | \n", "32 | \n", "0CZPE007DN0111B4K0000084 | \n", "NaN | \n", "
4 | \n", "1803242740_LUZAGAAA5MA009680_9223370390905621081 | \n", "LUZAGAAA5MA009680 | \n", "EP12 | \n", "2 | \n", "2022-02-27 08:05:54.726 | \n", "4.057,4.058,4.058,4.060,4.060,4.060,4.061,4.06... | \n", "389.5 | \n", "25 | \n", "84 | \n", "19,20,19,20,18,19,18,19,16,17,18,18,16,16,17,1... | \n", "... | \n", "4.294967e+09 | \n", "4.294967e+09 | \n", "255 | \n", "1641171093000 | \n", "96 | \n", "1 | \n", "96 | \n", "32 | \n", "0CZPE007DN0111B4K0000084 | \n", "NaN | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
1293 | \n", "1803242740_LUZAGAAA5MA009680_9223370390905615845 | \n", "LUZAGAAA5MA009680 | \n", "EP12 | \n", "2 | \n", "2022-02-27 08:05:59.962 | \n", "4.067,4.069,4.069,4.070,4.070,4.070,4.071,4.07... | \n", "390.5 | \n", "25 | \n", "84 | \n", "18,18,18,18,17,18,17,18,16,16,16,17,15,16,15,1... | \n", "... | \n", "4.294967e+09 | \n", "4.294967e+09 | \n", "255 | \n", "1641157910000 | \n", "96 | \n", "1 | \n", "96 | \n", "32 | \n", "0CZPE007DN0111B4K0000084 | \n", "NaN | \n", "
1294 | \n", "1803242740_LUZAGAAA5MA009680_9223370390905615844 | \n", "LUZAGAAA5MA009680 | \n", "EP12 | \n", "2 | \n", "2022-02-27 08:05:59.963 | \n", "4.068,4.070,4.070,4.071,4.071,4.071,4.071,4.07... | \n", "390.5 | \n", "25 | \n", "84 | \n", "18,19,18,18,18,18,17,18,16,17,17,17,16,16,15,1... | \n", "... | \n", "4.294967e+09 | \n", "4.294967e+09 | \n", "255 | \n", "1641157687000 | \n", "96 | \n", "1 | \n", "96 | \n", "32 | \n", "0CZPE007DN0111B4K0000084 | \n", "NaN | \n", "
1295 | \n", "1803242740_LUZAGAAA5MA009680_9223370390905615844 | \n", "LUZAGAAA5MA009680 | \n", "EP12 | \n", "2 | \n", "2022-02-27 08:05:59.963 | \n", "4.069,4.070,4.071,4.071,4.071,4.071,4.071,4.07... | \n", "390.5 | \n", "25 | \n", "84 | \n", "18,19,18,19,18,18,17,18,16,17,17,17,16,16,16,1... | \n", "... | \n", "4.294967e+09 | \n", "4.294967e+09 | \n", "255 | \n", "1641157336000 | \n", "96 | \n", "1 | \n", "96 | \n", "32 | \n", "0CZPE007DN0111B4K0000084 | \n", "NaN | \n", "
1296 | \n", "1803242740_LUZAGAAA5MA009680_9223370390905615843 | \n", "LUZAGAAA5MA009680 | \n", "EP12 | \n", "2 | \n", "2022-02-27 08:05:59.964 | \n", "4.083,4.084,4.085,4.084,4.085,4.085,4.087,4.08... | \n", "391.7 | \n", "26 | \n", "84 | \n", "14,14,13,14,13,13,12,12,11,12,11,11,10,11,10,1... | \n", "... | \n", "4.294967e+09 | \n", "4.294967e+09 | \n", "255 | \n", "1641153388000 | \n", "96 | \n", "1 | \n", "96 | \n", "32 | \n", "0CZPE007DN0111B4K0000084 | \n", "NaN | \n", "
1297 | \n", "1803242740_LUZAGAAA5MA009680_9223370390905615843 | \n", "LUZAGAAA5MA009680 | \n", "EP12 | \n", "2 | \n", "2022-02-27 08:05:59.964 | \n", "4.083,4.084,4.085,4.085,4.085,4.087,4.088,4.08... | \n", "392.0 | \n", "25 | \n", "84 | \n", "14,14,14,14,13,13,12,13,12,12,11,12,11,11,10,1... | \n", "... | \n", "4.294967e+09 | \n", "4.294967e+09 | \n", "255 | \n", "1641152216000 | \n", "96 | \n", "1 | \n", "96 | \n", "32 | \n", "0CZPE007DN0111B4K0000084 | \n", "NaN | \n", "
1298 rows × 90 columns
\n", "