沥青定性,沥青定量,每日预测逻辑调整,液化气调试进度90%
This commit is contained in:
parent
3e9791f5c6
commit
1e9a74ad08
Binary file not shown.
Binary file not shown.
@ -2,7 +2,7 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"execution_count": 43,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -18,6 +18,7 @@
|
||||
"import numpy as np\n",
|
||||
"# 变量定义\n",
|
||||
"login_url = \"http://10.200.32.39/jingbo-api/api/server/login\"\n",
|
||||
"login_push_url = \"http://10.200.32.39/jingbo-api/api/server/login\"\n",
|
||||
"# query_data_list_item_nos_url\n",
|
||||
"search_url = \"http://10.200.32.39/jingbo-api/api/warehouse/dwDataItem/queryByItemNos\" #jingbo-dev/api/warehouse/dwDataItem/queryDataListItemNos\n",
|
||||
"upload_url = \"http://10.200.32.39/jingbo-api/api/dw/dataValue/pushDataValueList\"\n",
|
||||
@ -46,11 +47,43 @@
|
||||
" \"funcOperation\": \"获取token\"\n",
|
||||
"}\n",
|
||||
"\n",
|
||||
"login_push_data = {\n",
|
||||
" \"data\": {\n",
|
||||
" \"account\": \"api_dev\",\n",
|
||||
" \"password\": \"ZTEwYWRjMzk0OWJhNTlhYmJlNTZlMDU3ZjIwZjg4M2U=\",\n",
|
||||
" \"tenantHashCode\": \"8a4577dbd919675758d57999a1e891fe\",\n",
|
||||
" \"terminal\": \"API\"\n",
|
||||
" },\n",
|
||||
" \"funcModule\": \"API\",\n",
|
||||
" \"funcOperation\": \"获取token\"\n",
|
||||
"}\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"read_file_path_name = \"定性模型数据项12-11.xlsx\"\n",
|
||||
"one_cols = []\n",
|
||||
"two_cols = []\n",
|
||||
"\n",
|
||||
"def get_head_auth():\n",
|
||||
" login_res = requests.post(url=login_url, json=login_data, timeout=(3, 5))\n",
|
||||
" text = json.loads(login_res.text)\n",
|
||||
" if text[\"status\"]:\n",
|
||||
" token = text[\"data\"][\"accessToken\"]\n",
|
||||
" return token\n",
|
||||
" else:\n",
|
||||
" print(\"获取认证失败\")\n",
|
||||
" return None\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def get_head_push_auth():\n",
|
||||
" login_res = requests.post(url=login_push_url, json=login_push_data, timeout=(3, 5))\n",
|
||||
" text = json.loads(login_res.text)\n",
|
||||
" if text[\"status\"]:\n",
|
||||
" token = text[\"data\"][\"accessToken\"]\n",
|
||||
" return token\n",
|
||||
" else:\n",
|
||||
" print(\"获取认证失败\")\n",
|
||||
" return None\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def update_e_value(file_path, column_index, threshold):\n",
|
||||
" \"\"\"\n",
|
||||
@ -1068,12 +1101,28 @@
|
||||
" data_df[\"dataDate\"] = data_df[\"dataDate\"].dt.strftime('%Y-%m-%d')\n",
|
||||
" save_queryDataListItemNos_xls(data_df,dataItemNoList)\n",
|
||||
"\n",
|
||||
"def main(start_date=None,token=None,token_push=None):\n",
|
||||
" if start_date is None:\n",
|
||||
" start_date = datetime.now()\n",
|
||||
" if token is None:\n",
|
||||
" token = get_head_auth()\n",
|
||||
" if token_push is None:\n",
|
||||
" token_push = get_head_push_auth()\n",
|
||||
" date = start_date.strftime('%Y%m%d')\n",
|
||||
" print(date)\n",
|
||||
" updateExcelData(date,token)\n",
|
||||
" queryDataListItemNos(token=token)\n",
|
||||
" update_e_value('定性模型数据项12-11.xlsx', 8, 1000)\n",
|
||||
" x = qualitativeModel()\n",
|
||||
" print('**************************************************预测结果:',x)\n",
|
||||
" cur_time,cur_time2 = getNow(date)\n",
|
||||
" pushData(cur_time,x,token)\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"execution_count": 44,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -1113,69 +1162,24 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# if __name__ == \"__main__\":\n",
|
||||
" # def main(date='',token=None):\n",
|
||||
" # updateExcelData(date,token)\n",
|
||||
" # queryDataListItemNos(token=token)\n",
|
||||
" # update_e_value('定性模型数据项12-11.xlsx', 8, 1000)\n",
|
||||
" # x = qualitativeModel()\n",
|
||||
" # print('**************************************************预测结果:',x)\n",
|
||||
" # # cur_time,cur_time2 = getNow(date)\n",
|
||||
" # # pushData(cur_time,x,token)\n",
|
||||
"\n",
|
||||
"# print(\"运行中...\")\n",
|
||||
"# # 每天定时12点运行\n",
|
||||
"# while True:\n",
|
||||
"# # 获取当前时间\n",
|
||||
"# current_time = time.strftime(\"%H:%M:%S\", time.localtime())\n",
|
||||
"# try:\n",
|
||||
"# # 判断当前时间是否为执行任务的时间点\n",
|
||||
"# if current_time == \"12:00:00\":\n",
|
||||
"# try:\n",
|
||||
"# main()\n",
|
||||
"# except Exception as e:\n",
|
||||
"# print(f\"12点执行失败: {e}\")\n",
|
||||
"# # 等待到12点30分再次执行\n",
|
||||
"# while current_time != \"12:30:00\":\n",
|
||||
"# current_time = time.strftime(\"%H:%M:%S\", time.localtime())\n",
|
||||
"# time.sleep(1)\n",
|
||||
"# try:\n",
|
||||
"# main()\n",
|
||||
"# except Exception as e:\n",
|
||||
"# print(f\"12点30分也执行失败: {e}\")\n",
|
||||
"# elif current_time == \"20:00:00\":\n",
|
||||
"# print(\"更新前一天数据\")\n",
|
||||
"# token = getLogToken()\n",
|
||||
"# updateYesterdayExcelData(token=token)\n",
|
||||
" \n",
|
||||
"# time.sleep(1)\n",
|
||||
"# except Exception as e:\n",
|
||||
"# print(f\"执行失败: {e}\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"execution_count": 45,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"20250401\n"
|
||||
"运行中...\n",
|
||||
"20250408\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_1412\\43143909.py:66: FutureWarning: DataFrame.applymap has been deprecated. Use DataFrame.map instead.\n",
|
||||
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_25972\\2961115944.py:99: FutureWarning: DataFrame.applymap has been deprecated. Use DataFrame.map instead.\n",
|
||||
" df = df.applymap(lambda x: float(x) if isinstance(x, (int, float)) else x)\n",
|
||||
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_1412\\43143909.py:70: FutureWarning: DataFrame.fillna with 'method' is deprecated and will raise in a future version. Use obj.ffill() or obj.bfill() instead.\n",
|
||||
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_25972\\2961115944.py:103: FutureWarning: DataFrame.fillna with 'method' is deprecated and will raise in a future version. Use obj.ffill() or obj.bfill() instead.\n",
|
||||
" df = df.fillna(method='ffill')\n"
|
||||
]
|
||||
},
|
||||
@ -1201,37 +1205,79 @@
|
||||
"1 3630 2972.5098 1 4982.8366 5522.676 \n",
|
||||
"昨日计划提货偏差改之前 478.28\n",
|
||||
"昨日计划提货偏差改之后 539.8394000000008\n",
|
||||
"**************************************************预测结果: 3567.73\n"
|
||||
"**************************************************预测结果: 3567.73\n",
|
||||
"更新前一天数据\n",
|
||||
"更新数据前\n",
|
||||
" 日期 京博指导价 70号沥青开工率 资金因素 昨日计划提货偏差 生产情况 基质沥青库存 下游客户价格预期 \\\n",
|
||||
"1401 2025-04-08 3450 36.784 1 478.28 6000 107945.963078 3630 \n",
|
||||
"\n",
|
||||
" 即期成本 订单结构 计划产量 京博产量 \n",
|
||||
"1401 3096.5238 1 4982.8366 5522.676 \n",
|
||||
"日期存在,即将更新\n",
|
||||
"新数据 [3500.0, 36.784, '', 478.28, '', 107945.9630779, '', 2972.5098, '', 4982.8366, 5522.676]\n",
|
||||
"更新数据后\n",
|
||||
" 日期 京博指导价 70号沥青开工率 资金因素 昨日计划提货偏差 生产情况 基质沥青库存 下游客户价格预期 \\\n",
|
||||
"1401 2025-04-08 3450 36.784 1 478.28 6000 107945.963078 3630 \n",
|
||||
"\n",
|
||||
" 即期成本 订单结构 计划产量 京博产量 \n",
|
||||
"1401 3096.5238 1 4982.8366 5522.676 \n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ename": "KeyboardInterrupt",
|
||||
"evalue": "",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[1;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)",
|
||||
"Cell \u001b[1;32mIn[45], line 15\u001b[0m\n\u001b[0;32m 13\u001b[0m token \u001b[38;5;241m=\u001b[39m getLogToken()\n\u001b[0;32m 14\u001b[0m updateYesterdayExcelData(token\u001b[38;5;241m=\u001b[39mtoken)\n\u001b[1;32m---> 15\u001b[0m time\u001b[38;5;241m.\u001b[39msleep(\u001b[38;5;241m1\u001b[39m)\n\u001b[0;32m 16\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[0;32m 17\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m执行失败: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00me\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n",
|
||||
"\u001b[1;31mKeyboardInterrupt\u001b[0m: "
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# 重新上传定性数据\n",
|
||||
"\n",
|
||||
"def main(date='',token=None):\n",
|
||||
" updateExcelData(date,token)\n",
|
||||
" queryDataListItemNos(token=token)\n",
|
||||
" update_e_value('定性模型数据项12-11.xlsx', 8, 1000)\n",
|
||||
" x = qualitativeModel()\n",
|
||||
" print('**************************************************预测结果:',x)\n",
|
||||
" # cur_time,cur_time2 = getNow(date)\n",
|
||||
" # pushData(cur_time,x,token)\n",
|
||||
"if __name__ == \"__main__\":\n",
|
||||
" print(\"运行中...\")\n",
|
||||
" # 每天定时12点运行\n",
|
||||
" while True:\n",
|
||||
" # 获取当前时间\n",
|
||||
" current_time = time.strftime(\"%H:%M:%S\", time.localtime())\n",
|
||||
" try:\n",
|
||||
" # 判断当前时间是否为执行任务的时间点\n",
|
||||
" if current_time == \"12:00:00\":\n",
|
||||
" main()\n",
|
||||
" elif current_time == \"20:00:00\":\n",
|
||||
" print(\"更新前一天数据\")\n",
|
||||
" token = getLogToken()\n",
|
||||
" updateYesterdayExcelData(token=token)\n",
|
||||
" time.sleep(1)\n",
|
||||
" except Exception as e:\n",
|
||||
" print(f\"执行失败: {e}\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# # 重新上传定性数据\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"start_date = datetime(2025, 4, 1)\n",
|
||||
"end_date = datetime(2025, 4, 2)\n",
|
||||
"token = getLogToken()\n",
|
||||
"while start_date < end_date:\n",
|
||||
" print(start_date.strftime('%Y%m%d'))\n",
|
||||
" main(start_date.strftime('%Y%m%d'),token)\n",
|
||||
" start_date += timedelta(days=1)\n",
|
||||
" time.sleep(5)\n",
|
||||
"\n",
|
||||
"# start_date = datetime(2025, 4, 1)\n",
|
||||
"# end_date = datetime(2025, 4, 2)\n",
|
||||
"# token = getLogToken()\n",
|
||||
"# while start_date < end_date:\n",
|
||||
"# main(start_date,token)\n",
|
||||
"# start_date += timedelta(days=1)\n",
|
||||
"# time.sleep(5)\n",
|
||||
" \n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -1244,7 +1290,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@ -1271,7 +1317,7 @@
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "base",
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
|
@ -2,7 +2,7 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 26,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -169,26 +169,6 @@
|
||||
"\n",
|
||||
"# xls文件处理\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def write_xls(data,date):\n",
|
||||
" # 创建一个Workbook对象\n",
|
||||
" workbook = xlwt.Workbook()\n",
|
||||
"\n",
|
||||
" # 创建一个Sheet对象,可指定名称\n",
|
||||
" sheet = workbook.load('Sheet1')\n",
|
||||
"\n",
|
||||
" # 写入数据行\n",
|
||||
" for row_index, row_data in enumerate(data):\n",
|
||||
" for col_index, cell_data in enumerate(row_data):\n",
|
||||
" sheet.write(row_index, col_index, cell_data)\n",
|
||||
"\n",
|
||||
" # 保存Workbook到文件\n",
|
||||
" workbook.save(get_cur_time(date)[0] + '.xls')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def get_cur_time(date = ''):\n",
|
||||
" if date == '':\n",
|
||||
" now = datetime.now()\n",
|
||||
@ -219,8 +199,6 @@
|
||||
" print(\"获取认证失败\")\n",
|
||||
" return None\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def upload_data_to_system(token_push,date):\n",
|
||||
" data = {\n",
|
||||
" \"funcModule\": \"数据表信息列表\",\n",
|
||||
@ -455,14 +433,6 @@
|
||||
" with open(Pkl_Filename, 'wb') as file: \n",
|
||||
" pickle.dump(grid_search_XGB, file)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
" \n",
|
||||
"\n",
|
||||
"\n",
|
||||
" \n",
|
||||
"\n",
|
||||
"def read_xls_data():\n",
|
||||
" global one_cols, two_cols\n",
|
||||
" # 打开 XLS 文件\n",
|
||||
@ -490,59 +460,16 @@
|
||||
" # 关闭 XLS 文件\n",
|
||||
" # workbook.close()\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def start():\n",
|
||||
"def start_3(date=None,token=None,token_push=None):\n",
|
||||
" '''预测上传数据'''\n",
|
||||
" read_xls_data()\n",
|
||||
"\n",
|
||||
" token = get_head_auth()\n",
|
||||
" if not token:\n",
|
||||
" return\n",
|
||||
" token_push = get_head_push_auth()\n",
|
||||
" if not token_push:\n",
|
||||
" return\n",
|
||||
"\n",
|
||||
" datas = get_data_value(token, one_cols[1:])\n",
|
||||
" if not datas:\n",
|
||||
" return\n",
|
||||
"\n",
|
||||
" # data_list = [two_cols, one_cols]\n",
|
||||
" append_rows = [get_cur_time()[1]]\n",
|
||||
" dataItemNo_dataValue = {}\n",
|
||||
" for data_value in datas:\n",
|
||||
" if \"dataValue\" not in data_value:\n",
|
||||
" print(data_value)\n",
|
||||
" dataItemNo_dataValue[data_value[\"dataItemNo\"]] = \"\"\n",
|
||||
" else:\n",
|
||||
" dataItemNo_dataValue[data_value[\"dataItemNo\"]] = data_value[\"dataValue\"]\n",
|
||||
" \n",
|
||||
" for value in one_cols[1:]:\n",
|
||||
" if value in dataItemNo_dataValue:\n",
|
||||
" append_rows.append(dataItemNo_dataValue[value])\n",
|
||||
" else:\n",
|
||||
" append_rows.append(\"\")\n",
|
||||
" save_xls(append_rows)\n",
|
||||
" \n",
|
||||
" # 获取当月的数据写入到指定文件\n",
|
||||
" queryDataListItemNos(token)\n",
|
||||
" optimize_Model()\n",
|
||||
" upload_data_to_system(token_push)\n",
|
||||
" # data_list.append(three_cols)\n",
|
||||
" # write_xls(data_list)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def start_3(date,token,token_push):\n",
|
||||
" '''预测上传数据'''\n",
|
||||
" read_xls_data()\n",
|
||||
"\n",
|
||||
" # token = get_head_auth()\n",
|
||||
" # if not token:\n",
|
||||
" # return\n",
|
||||
" # token_push = get_head_push_auth()\n",
|
||||
" # if not token_push:\n",
|
||||
" # return\n",
|
||||
" if date==None:\n",
|
||||
" date = datetime.now()\n",
|
||||
" if token==None:\n",
|
||||
" token = get_head_auth()\n",
|
||||
" if token_push==None:\n",
|
||||
" token = get_head_auth()\n",
|
||||
"\n",
|
||||
" datas = get_data_value(token, one_cols[1:],date)\n",
|
||||
" if not datas:\n",
|
||||
@ -571,126 +498,6 @@
|
||||
" # data_list.append(three_cols)\n",
|
||||
" # write_xls(data_list)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def start_1():\n",
|
||||
" '''更新数据'''\n",
|
||||
" print(\"更新当天数据\")\n",
|
||||
" read_xls_data()\n",
|
||||
"\n",
|
||||
" token = get_head_auth()\n",
|
||||
" if not token:\n",
|
||||
" return\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" datas = get_data_value(token, one_cols[1:])\n",
|
||||
" if not datas:\n",
|
||||
" return\n",
|
||||
"\n",
|
||||
" # data_list = [two_cols, one_cols]\n",
|
||||
" append_rows = [get_cur_time()[1]]\n",
|
||||
" dataItemNo_dataValue = {}\n",
|
||||
" for data_value in datas:\n",
|
||||
" if \"dataValue\" not in data_value:\n",
|
||||
" print(data_value)\n",
|
||||
" dataItemNo_dataValue[data_value[\"dataItemNo\"]] = \"\"\n",
|
||||
" else:\n",
|
||||
" dataItemNo_dataValue[data_value[\"dataItemNo\"]] = data_value[\"dataValue\"]\n",
|
||||
" \n",
|
||||
" for value in one_cols[1:]:\n",
|
||||
" if value in dataItemNo_dataValue:\n",
|
||||
" append_rows.append(dataItemNo_dataValue[value])\n",
|
||||
" else:\n",
|
||||
" append_rows.append(\"\")\n",
|
||||
" print(\"当天数据为:\",append_rows)\n",
|
||||
" save_xls_1(append_rows)\n",
|
||||
"\n",
|
||||
" \n",
|
||||
" # data_list.append(three_cols)\n",
|
||||
" # write_xls(data_list)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def start_2(date,token):\n",
|
||||
" '''更新数据'''\n",
|
||||
" read_xls_data()\n",
|
||||
"\n",
|
||||
" # token = get_head_auth()\n",
|
||||
" # if not token:\n",
|
||||
" # return\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" datas = get_data_value(token, one_cols[1:],date)\n",
|
||||
" if not datas:\n",
|
||||
" return\n",
|
||||
"\n",
|
||||
" # data_list = [two_cols, one_cols]\n",
|
||||
" append_rows = [get_cur_time(date=date)[1]]\n",
|
||||
" dataItemNo_dataValue = {}\n",
|
||||
" for data_value in datas:\n",
|
||||
" if \"dataValue\" not in data_value:\n",
|
||||
" print(data_value)\n",
|
||||
" dataItemNo_dataValue[data_value[\"dataItemNo\"]] = \"\"\n",
|
||||
" else:\n",
|
||||
" dataItemNo_dataValue[data_value[\"dataItemNo\"]] = data_value[\"dataValue\"]\n",
|
||||
" \n",
|
||||
" for value in one_cols[1:]:\n",
|
||||
" if value in dataItemNo_dataValue:\n",
|
||||
" append_rows.append(dataItemNo_dataValue[value])\n",
|
||||
" else:\n",
|
||||
" append_rows.append(\"\")\n",
|
||||
" print('新增数据:',append_rows)\n",
|
||||
" save_xls_1(append_rows)\n",
|
||||
"\n",
|
||||
" \n",
|
||||
" # data_list.append(three_cols)\n",
|
||||
" # write_xls(data_list)\n",
|
||||
" \n",
|
||||
"def save_xls_1(append_rows):\n",
|
||||
"\n",
|
||||
" # 打开xls文件\n",
|
||||
" workbook = xlrd.open_workbook('沥青数据项.xlsx')\n",
|
||||
"\n",
|
||||
" # 获取所有sheet的个数\n",
|
||||
" sheet_count = len(workbook.sheet_names())\n",
|
||||
"\n",
|
||||
" # 获取所有sheet的名称\n",
|
||||
" sheet_names = workbook.sheet_names()\n",
|
||||
"\n",
|
||||
" new_workbook = xlwt.Workbook()\n",
|
||||
" for i in range(sheet_count):\n",
|
||||
" # 获取当前sheet\n",
|
||||
" sheet = workbook.sheet_by_index(i)\n",
|
||||
"\n",
|
||||
" # 获取sheet的行数和列数\n",
|
||||
" row_count = sheet.nrows - 1\n",
|
||||
" col_count = sheet.ncols\n",
|
||||
" # 获取原有数据\n",
|
||||
" data = []\n",
|
||||
" for row in range(row_count):\n",
|
||||
" row_data = []\n",
|
||||
" for col in range(col_count):\n",
|
||||
" row_data.append(sheet.cell_value(row, col))\n",
|
||||
" data.append(row_data)\n",
|
||||
" # 创建xlwt的Workbook对象\n",
|
||||
" # 创建sheet\n",
|
||||
" new_sheet = new_workbook.add_sheet(sheet_names[i])\n",
|
||||
"\n",
|
||||
" # 将原有的数据写入新的sheet\n",
|
||||
" for row in range(row_count):\n",
|
||||
" for col in range(col_count):\n",
|
||||
" new_sheet.write(row, col, data[row][col])\n",
|
||||
"\n",
|
||||
" if i == 0:\n",
|
||||
" # 在新的sheet中添加数据\n",
|
||||
" for col in range(col_count):\n",
|
||||
" new_sheet.write(row_count, col, append_rows[col])\n",
|
||||
"\n",
|
||||
" # 保存新的xls文件\n",
|
||||
" new_workbook.save(\"沥青数据项.xlsx\") \n",
|
||||
"\n",
|
||||
" \n",
|
||||
" \n",
|
||||
" \n",
|
||||
"def check_data(dataItemNo):\n",
|
||||
" token = get_head_auth()\n",
|
||||
" if not token:\n",
|
||||
@ -700,7 +507,6 @@
|
||||
" if not datas:\n",
|
||||
" return\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def save_xls(append_rows):\n",
|
||||
"\n",
|
||||
" # 打开xls文件\n",
|
||||
@ -744,10 +550,6 @@
|
||||
" # 保存新的xls文件\n",
|
||||
" new_workbook.save(\"沥青数据项.xlsx\")\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def get_queryDataListItemNos_value(token, url, dataItemNoList, dateStart, dateEnd):\n",
|
||||
"\n",
|
||||
" search_data = {\n",
|
||||
@ -768,8 +570,6 @@
|
||||
" else:\n",
|
||||
" return None\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def save_queryDataListItemNos_xls(data_df,dataItemNoList):\n",
|
||||
"\n",
|
||||
" current_year_month = datetime.now().strftime('%Y-%m')\n",
|
||||
@ -837,9 +637,6 @@
|
||||
" # 保存新的xls文件\n",
|
||||
" new_workbook.save(\"沥青数据项.xlsx\")\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def queryDataListItemNos(token=None):\n",
|
||||
" df = pd.read_excel('沥青数据项.xlsx')\n",
|
||||
" dataItemNoList = df.iloc[0].tolist()[1:]\n",
|
||||
@ -894,7 +691,17 @@
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"运行中ing...\n",
|
||||
"18:13:56任务失败\n",
|
||||
"18:13:59任务失败\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"\n",
|
||||
"if __name__ == \"__main__\":\n",
|
||||
@ -903,16 +710,19 @@
|
||||
" while True:\n",
|
||||
" # 获取当前时间\n",
|
||||
" current_time = time.strftime(\"%H:%M:%S\", time.localtime())\n",
|
||||
" # print(current_time)\n",
|
||||
"\n",
|
||||
" # 判断当前时间是否为执行任务的时间点\n",
|
||||
" # if current_time == \"12:00:00\":\n",
|
||||
" if current_time == \"15:36:00\":\n",
|
||||
" print(\"执行定时任务\")\n",
|
||||
" main()\n",
|
||||
" time.sleep(1)\n",
|
||||
" elif current_time == \"15:40:00\":\n",
|
||||
" start_1()\n",
|
||||
" try:\n",
|
||||
" if current_time == \"17:05:00\":\n",
|
||||
" print(\"执行定时任务\")\n",
|
||||
" main()\n",
|
||||
" elif current_time == \"17:10:00\":\n",
|
||||
" print('更新数据')\n",
|
||||
" start_3()\n",
|
||||
" time.sleep(1)\n",
|
||||
" except :\n",
|
||||
" print(f\"{current_time}任务失败\")\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# # 检测数据准确性, 需要检测放开\n",
|
||||
@ -924,16 +734,7 @@
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"更新当天数据\n",
|
||||
"当天数据为: ['2025-04-08', '', '', 0.05, 0.25, 3680.0, 0.7, 0.0, 0.0, 3450.0, 7.9, 0.15, 0.2, 3400.0, 10.27, '', 3450.0, 65.88, 64.36, '', '', '', '', '', '', '', '', '', 3096.5238, '', '', '', '', '']\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# start_date = datetime(2025, 4, 8)\n",
|
||||
"# end_date = datetime(2025, 4, 9)\n",
|
||||
@ -941,18 +742,201 @@
|
||||
"\n",
|
||||
"# token_push = get_head_push_auth()\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# while start_date < end_date:\n",
|
||||
" # main(start_date,token,token_push)\n",
|
||||
"# start_date += timedelta(days=1)\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"### 代码备份:\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class codeBackup:\n",
|
||||
" def save_xls_1(append_rows):\n",
|
||||
"\n",
|
||||
" # 打开xls文件\n",
|
||||
" workbook = xlrd.open_workbook('沥青数据项.xlsx')\n",
|
||||
"\n",
|
||||
" # 获取所有sheet的个数\n",
|
||||
" sheet_count = len(workbook.sheet_names())\n",
|
||||
"\n",
|
||||
" # 获取所有sheet的名称\n",
|
||||
" sheet_names = workbook.sheet_names()\n",
|
||||
"\n",
|
||||
" new_workbook = xlwt.Workbook()\n",
|
||||
" for i in range(sheet_count):\n",
|
||||
" # 获取当前sheet\n",
|
||||
" sheet = workbook.sheet_by_index(i)\n",
|
||||
"\n",
|
||||
" # 获取sheet的行数和列数\n",
|
||||
" row_count = sheet.nrows - 1\n",
|
||||
" col_count = sheet.ncols\n",
|
||||
" # 获取原有数据\n",
|
||||
" data = []\n",
|
||||
" for row in range(row_count):\n",
|
||||
" row_data = []\n",
|
||||
" for col in range(col_count):\n",
|
||||
" row_data.append(sheet.cell_value(row, col))\n",
|
||||
" data.append(row_data)\n",
|
||||
" # 创建xlwt的Workbook对象\n",
|
||||
" # 创建sheet\n",
|
||||
" new_sheet = new_workbook.add_sheet(sheet_names[i])\n",
|
||||
"\n",
|
||||
" # 将原有的数据写入新的sheet\n",
|
||||
" for row in range(row_count):\n",
|
||||
" for col in range(col_count):\n",
|
||||
" new_sheet.write(row, col, data[row][col])\n",
|
||||
"\n",
|
||||
" if i == 0:\n",
|
||||
" # 在新的sheet中添加数据\n",
|
||||
" for col in range(col_count):\n",
|
||||
" new_sheet.write(row_count, col, append_rows[col])\n",
|
||||
"\n",
|
||||
" # 保存新的xls文件\n",
|
||||
" new_workbook.save(\"沥青数据项.xlsx\") \n",
|
||||
"\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def start_2(date,token):\n",
|
||||
" '''更新数据'''\n",
|
||||
" read_xls_data()\n",
|
||||
"\n",
|
||||
" # token = get_head_auth()\n",
|
||||
" # if not token:\n",
|
||||
" # return\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" datas = get_data_value(token, one_cols[1:],date)\n",
|
||||
" if not datas:\n",
|
||||
" return\n",
|
||||
"\n",
|
||||
" # data_list = [two_cols, one_cols]\n",
|
||||
" append_rows = [get_cur_time(date=date)[1]]\n",
|
||||
" dataItemNo_dataValue = {}\n",
|
||||
" for data_value in datas:\n",
|
||||
" if \"dataValue\" not in data_value:\n",
|
||||
" print(data_value)\n",
|
||||
" dataItemNo_dataValue[data_value[\"dataItemNo\"]] = \"\"\n",
|
||||
" else:\n",
|
||||
" dataItemNo_dataValue[data_value[\"dataItemNo\"]] = data_value[\"dataValue\"]\n",
|
||||
" \n",
|
||||
" for value in one_cols[1:]:\n",
|
||||
" if value in dataItemNo_dataValue:\n",
|
||||
" append_rows.append(dataItemNo_dataValue[value])\n",
|
||||
" else:\n",
|
||||
" append_rows.append(\"\")\n",
|
||||
" print('新增数据:',append_rows)\n",
|
||||
" save_xls_1(append_rows)\n",
|
||||
"\n",
|
||||
" \n",
|
||||
" # data_list.append(three_cols)\n",
|
||||
" # write_xls(data_list)\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" def write_xls(data,date):\n",
|
||||
" # 创建一个Workbook对象\n",
|
||||
" workbook = xlwt.Workbook()\n",
|
||||
"\n",
|
||||
" # 创建一个Sheet对象,可指定名称\n",
|
||||
" sheet = workbook.load('Sheet1')\n",
|
||||
"\n",
|
||||
" # 写入数据行\n",
|
||||
" for row_index, row_data in enumerate(data):\n",
|
||||
" for col_index, cell_data in enumerate(row_data):\n",
|
||||
" sheet.write(row_index, col_index, cell_data)\n",
|
||||
"\n",
|
||||
" # 保存Workbook到文件\n",
|
||||
" workbook.save(get_cur_time(date)[0] + '.xls')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
" def start():\n",
|
||||
" '''预测上传数据'''\n",
|
||||
" read_xls_data()\n",
|
||||
"\n",
|
||||
" token = get_head_auth()\n",
|
||||
" if not token:\n",
|
||||
" return\n",
|
||||
" token_push = get_head_push_auth()\n",
|
||||
" if not token_push:\n",
|
||||
" return\n",
|
||||
"\n",
|
||||
" datas = get_data_value(token, one_cols[1:])\n",
|
||||
" if not datas:\n",
|
||||
" return\n",
|
||||
"\n",
|
||||
" # data_list = [two_cols, one_cols]\n",
|
||||
" append_rows = [get_cur_time()[1]]\n",
|
||||
" dataItemNo_dataValue = {}\n",
|
||||
" for data_value in datas:\n",
|
||||
" if \"dataValue\" not in data_value:\n",
|
||||
" print(data_value)\n",
|
||||
" dataItemNo_dataValue[data_value[\"dataItemNo\"]] = \"\"\n",
|
||||
" else:\n",
|
||||
" dataItemNo_dataValue[data_value[\"dataItemNo\"]] = data_value[\"dataValue\"]\n",
|
||||
" \n",
|
||||
" for value in one_cols[1:]:\n",
|
||||
" if value in dataItemNo_dataValue:\n",
|
||||
" append_rows.append(dataItemNo_dataValue[value])\n",
|
||||
" else:\n",
|
||||
" append_rows.append(\"\")\n",
|
||||
" save_xls(append_rows)\n",
|
||||
" \n",
|
||||
" # 获取当月的数据写入到指定文件\n",
|
||||
" queryDataListItemNos(token)\n",
|
||||
" optimize_Model()\n",
|
||||
" upload_data_to_system(token_push)\n",
|
||||
" # data_list.append(three_cols)\n",
|
||||
" # write_xls(data_list)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
" def start_1():\n",
|
||||
" '''更新数据'''\n",
|
||||
" print(\"更新当天数据\")\n",
|
||||
" read_xls_data()\n",
|
||||
"\n",
|
||||
" token = get_head_auth()\n",
|
||||
" if not token:\n",
|
||||
" return\n",
|
||||
" \n",
|
||||
"\n",
|
||||
" datas = get_data_value(token, one_cols[1:])\n",
|
||||
" if not datas:\n",
|
||||
" return\n",
|
||||
"\n",
|
||||
" # data_list = [two_cols, one_cols]\n",
|
||||
" append_rows = [get_cur_time()[1]]\n",
|
||||
" dataItemNo_dataValue = {}\n",
|
||||
" for data_value in datas:\n",
|
||||
" if \"dataValue\" not in data_value:\n",
|
||||
" print(data_value)\n",
|
||||
" dataItemNo_dataValue[data_value[\"dataItemNo\"]] = \"\"\n",
|
||||
" else:\n",
|
||||
" dataItemNo_dataValue[data_value[\"dataItemNo\"]] = data_value[\"dataValue\"]\n",
|
||||
" \n",
|
||||
" for value in one_cols[1:]:\n",
|
||||
" if value in dataItemNo_dataValue:\n",
|
||||
" append_rows.append(dataItemNo_dataValue[value])\n",
|
||||
" else:\n",
|
||||
" append_rows.append(\"\")\n",
|
||||
" print(\"当天数据为:\",append_rows)\n",
|
||||
" save_xls_1(append_rows)\n",
|
||||
"\n",
|
||||
" \n",
|
||||
" # data_list.append(three_cols)\n",
|
||||
" # write_xls(data_list)\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "base",
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
|
Binary file not shown.
@ -2,7 +2,7 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"execution_count": 15,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@ -69,7 +69,7 @@
|
||||
" \"funcOperation\": \"获取token\"\n",
|
||||
"}\n",
|
||||
"\n",
|
||||
"read_file_path_name = \"液化气数据.xls\"\n",
|
||||
"read_file_path_name = \"液化气数据.xlsx\"\n",
|
||||
"one_cols = []\n",
|
||||
"two_cols = []\n",
|
||||
"\n",
|
||||
@ -281,7 +281,7 @@
|
||||
" \n",
|
||||
"def forecast_price():\n",
|
||||
" # df_test = pd.read_csv('定价模型数据收集0212.csv')\n",
|
||||
" df_test = pd.read_excel('液化气数据.xls')\n",
|
||||
" df_test = pd.read_excel('液化气数据.xlsx')\n",
|
||||
" df_test.drop([0],inplace=True)\n",
|
||||
" try:\n",
|
||||
" df_test['Date']=pd.to_datetime(df_test['Date'], format='%m/%d/%Y',infer_datetime_format=True)\n",
|
||||
@ -333,7 +333,7 @@
|
||||
"\n",
|
||||
" pd.set_option('display.max_rows',40) \n",
|
||||
" pd.set_option('display.max_columns',40) \n",
|
||||
" df_test = pd.read_excel('液化气数据.xls')\n",
|
||||
" df_test = pd.read_excel('液化气数据.xlsx')\n",
|
||||
" df_test.drop([0],inplace=True)\n",
|
||||
" try:\n",
|
||||
" df_test['Date']=pd.to_datetime(df_test['Date'], format='%m/%d/%Y',infer_datetime_format=True)\n",
|
||||
@ -561,7 +561,7 @@
|
||||
" print('更新数据后')\n",
|
||||
" print(df.tail(1))\n",
|
||||
" # 使用pandas保存Excel文件\n",
|
||||
" df.to_excel(\"液化气数据.xls\", index=False, engine='openpyxl')\n",
|
||||
" df.to_excel(\"液化气数据.xlsx\", index=False, engine='openpyxl')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def read_xls_data_bak():\n",
|
||||
@ -627,7 +627,7 @@
|
||||
" append_rows.append(dataItemNo_dataValue[value])\n",
|
||||
" else:\n",
|
||||
" append_rows.append(\"\")\n",
|
||||
" save_xls(append_rows)\n",
|
||||
" save_xlsx(append_rows)\n",
|
||||
" \n",
|
||||
" \n",
|
||||
" # 获取当月的数据写入到指定文件\n",
|
||||
@ -706,7 +706,7 @@
|
||||
"def save_xls_1(append_rows):\n",
|
||||
"\n",
|
||||
" # 打开xls文件\n",
|
||||
" workbook = xlrd.open_workbook('液化气数据.xls')\n",
|
||||
" workbook = xlrd.open_workbook('液化气数据.xlsx')\n",
|
||||
"\n",
|
||||
" # 获取所有sheet的个数\n",
|
||||
" sheet_count = len(workbook.sheet_names())\n",
|
||||
@ -744,12 +744,12 @@
|
||||
" new_sheet.write(row_count, col, append_rows[col])\n",
|
||||
"\n",
|
||||
" # 保存新的xls文件\n",
|
||||
" new_workbook.save(\"液化气数据.xls\") \n",
|
||||
" new_workbook.save(\"液化气数据.xlsx\") \n",
|
||||
"\n",
|
||||
"def save_xls_2(append_rows):\n",
|
||||
" try:\n",
|
||||
" # 读取现有数据(假设第一行为列名)\n",
|
||||
" df = pd.read_excel('液化气数据.xls', sheet_name=0)\n",
|
||||
" df = pd.read_excel('液化气数据.xlsx', sheet_name=0)\n",
|
||||
" print(df.columns)\n",
|
||||
" append_rows = pd.DataFrame(append_rows, index=df.columns)\n",
|
||||
" # 创建新数据行\n",
|
||||
@ -772,11 +772,11 @@
|
||||
" print(f\"插入 {new_date} 新数据\")\n",
|
||||
" \n",
|
||||
" # 保存更新后的数据\n",
|
||||
" df.to_excel('液化气数据.xls', index=False, engine='openpyxl')\n",
|
||||
" df.to_excel('液化气数据.xlsx', index=False, engine='openpyxl')\n",
|
||||
" \n",
|
||||
" except FileNotFoundError:\n",
|
||||
" # 如果文件不存在则创建新文件\n",
|
||||
" pd.DataFrame([append_rows]).to_excel('液化气数据.xls', index=False, engine='openpyxl')\n",
|
||||
" pd.DataFrame([append_rows]).to_excel('液化气数据.xlsx', index=False, engine='openpyxl')\n",
|
||||
" except Exception as e:\n",
|
||||
" print(f\"保存数据时发生错误: {str(e)}\")\n",
|
||||
" \n",
|
||||
@ -790,17 +790,43 @@
|
||||
" if not datas:\n",
|
||||
" return\n",
|
||||
"\n",
|
||||
"def save_xlsx(append_rows):\n",
|
||||
" from openpyxl import load_workbook\n",
|
||||
"\n",
|
||||
" # 加载现有工作簿\n",
|
||||
" workbook = load_workbook('液化气数据.xlsx')\n",
|
||||
" \n",
|
||||
" # 创建新工作簿并复制所有工作表结构\n",
|
||||
" new_workbook = load_workbook('液化气数据.xlsx')\n",
|
||||
" \n",
|
||||
" # 遍历所有工作表\n",
|
||||
" for sheetname in workbook.sheetnames:\n",
|
||||
" sheet = workbook[sheetname]\n",
|
||||
" new_sheet = new_workbook[sheetname]\n",
|
||||
" \n",
|
||||
" # 获取原始数据行数\n",
|
||||
" row_count = sheet.max_row\n",
|
||||
" \n",
|
||||
" # 在第一个工作表中追加数据\n",
|
||||
" if sheetname == workbook.sheetnames[0]:\n",
|
||||
" # 追加新行数据\n",
|
||||
" new_row = (row_count + 1, )\n",
|
||||
" for col_idx, value in enumerate(append_rows, start=1):\n",
|
||||
" new_sheet.cell(row=row_count+1, column=col_idx, value=value)\n",
|
||||
"\n",
|
||||
" # 保存修改后的工作簿\n",
|
||||
" new_workbook.save(\"液化气数据.xlsx\")\n",
|
||||
"\n",
|
||||
"def save_xls(append_rows):\n",
|
||||
"\n",
|
||||
" # 修改文件打开方式\n",
|
||||
" try:\n",
|
||||
" # 尝试用xlrd打开旧版xls文件\n",
|
||||
" workbook = xlrd.open_workbook('液化气数据.xls')\n",
|
||||
" workbook = xlrd.open_workbook('液化气数据.xlsx')\n",
|
||||
" except:\n",
|
||||
" # 使用openpyxl打开新版xlsx文件\n",
|
||||
" from openpyxl import load_workbook\n",
|
||||
" workbook = load_workbook('液化气数据.xls')\n",
|
||||
" workbook = load_workbook('液化气数据.xlsx')\n",
|
||||
"\n",
|
||||
" # 获取所有sheet的个数\n",
|
||||
" sheet_count = len(workbook.sheet_names())\n",
|
||||
@ -838,7 +864,7 @@
|
||||
" new_sheet.write(row_count, col, append_rows[col])\n",
|
||||
"\n",
|
||||
" # 保存新的xls文件\n",
|
||||
" new_workbook.save(\"液化气数据.xls\")\n",
|
||||
" new_workbook.save(\"液化气数据.xlsx\")\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
@ -867,79 +893,111 @@
|
||||
" else:\n",
|
||||
" return None\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def save_queryDataListItemNos_xls(data_df,dataItemNoList):\n",
|
||||
"\n",
|
||||
" current_year_month = datetime.now().strftime('%Y-%m')\n",
|
||||
" grouped = data_df.groupby(\"dataDate\")\n",
|
||||
"\n",
|
||||
" # 打开xls文件\n",
|
||||
" workbook = xlrd.open_workbook('液化气数据.xls')\n",
|
||||
"\n",
|
||||
" # 获取所有sheet的个数\n",
|
||||
" sheet_count = len(workbook.sheet_names())\n",
|
||||
"\n",
|
||||
" # 获取所有sheet的名称\n",
|
||||
" sheet_names = workbook.sheet_names()\n",
|
||||
"\n",
|
||||
" new_workbook = xlwt.Workbook()\n",
|
||||
" for i in range(sheet_count):\n",
|
||||
" # 获取当前sheet\n",
|
||||
" sheet = workbook.sheet_by_index(i)\n",
|
||||
"\n",
|
||||
" # 获取sheet的行数和列数\n",
|
||||
" row_count = sheet.nrows\n",
|
||||
" col_count = sheet.ncols\n",
|
||||
" # 获取原有数据\n",
|
||||
" data = []\n",
|
||||
" for row in range(row_count):\n",
|
||||
" row_data = []\n",
|
||||
" for col in range(col_count):\n",
|
||||
" row_data.append(sheet.cell_value(row, col))\n",
|
||||
" data.append(row_data)\n",
|
||||
"\n",
|
||||
" # 创建xlwt的Workbook对象\n",
|
||||
" # 创建sheet\n",
|
||||
" new_sheet = new_workbook.add_sheet(sheet_names[i])\n",
|
||||
"\n",
|
||||
" # 使用openpyxl打开xlsx文件\n",
|
||||
" from openpyxl import load_workbook\n",
|
||||
" workbook = load_workbook('液化气数据.xlsx')\n",
|
||||
"\n",
|
||||
" # 创建新工作簿\n",
|
||||
" new_workbook = load_workbook('液化气数据.xlsx')\n",
|
||||
" \n",
|
||||
" for sheetname in workbook.sheetnames:\n",
|
||||
" sheet = workbook[sheetname]\n",
|
||||
" new_sheet = new_workbook[sheetname]\n",
|
||||
" \n",
|
||||
" current_year_month_row = 0\n",
|
||||
" # 将原有的数据写入新的sheet\n",
|
||||
" for row in range(row_count):\n",
|
||||
" for col in range(col_count):\n",
|
||||
" col0 = data[row][0]\n",
|
||||
" # print(\"col0\",col0[:7])\n",
|
||||
" if col0[:7] == current_year_month:\n",
|
||||
" current_year_month_row += 1\n",
|
||||
" break\n",
|
||||
" new_sheet.write(row, col, data[row][col])\n",
|
||||
" # 查找当前月份数据起始行\n",
|
||||
" for row_idx, row in enumerate(sheet.iter_rows(values_only=True), 1):\n",
|
||||
" if str(row[0]).startswith(current_year_month):\n",
|
||||
" current_year_month_row += 1\n",
|
||||
"\n",
|
||||
"\n",
|
||||
" # print(\"current_year_month_row\",current_year_month_row)\n",
|
||||
" if i == 0:\n",
|
||||
" rowFlag = 0\n",
|
||||
" # 查看每组数据\n",
|
||||
" for date, group in grouped:\n",
|
||||
" new_sheet.write(row_count + rowFlag - current_year_month_row, 0, date)\n",
|
||||
" for j in range(len(dataItemNoList)):\n",
|
||||
" dataItemNo = dataItemNoList[j]\n",
|
||||
"\n",
|
||||
" # for dataItemNo in dataItemNoList:\n",
|
||||
" # 追加新数据\n",
|
||||
" if sheetname == workbook.sheetnames[0]:\n",
|
||||
" start_row = sheet.max_row - current_year_month_row + 1\n",
|
||||
" for row_idx, (date, group) in enumerate(grouped, start=start_row):\n",
|
||||
" new_sheet.cell(row=row_idx, column=1, value=date)\n",
|
||||
" for j, dataItemNo in enumerate(dataItemNoList, start=2):\n",
|
||||
" if group[group[\"dataItemNo\"] == dataItemNo][\"dataValue\"].values:\n",
|
||||
" new_sheet.cell(row=row_idx, column=j, \n",
|
||||
" value=group[group[\"dataItemNo\"] == dataItemNo][\"dataValue\"].values[0])\n",
|
||||
"\n",
|
||||
" new_sheet.write(row_count + rowFlag - current_year_month_row, j + 1, group[group[\"dataItemNo\"] == dataItemNo][\"dataValue\"].values[0])\n",
|
||||
" # 保存修改后的xlsx文件\n",
|
||||
" new_workbook.save(\"液化气数据.xlsx\")\n",
|
||||
"\n",
|
||||
" rowFlag += 1\n",
|
||||
"# def save_queryDataListItemNos_xls(data_df,dataItemNoList):\n",
|
||||
"\n",
|
||||
" # 保存新的xls文件\n",
|
||||
" new_workbook.save(\"液化气数据.xls\")\n",
|
||||
"# current_year_month = datetime.now().strftime('%Y-%m')\n",
|
||||
"# grouped = data_df.groupby(\"dataDate\")\n",
|
||||
"\n",
|
||||
"# # 打开xls文件\n",
|
||||
"# workbook = xlrd.open_workbook('液化气数据.xlsx')\n",
|
||||
"\n",
|
||||
"# # 获取所有sheet的个数\n",
|
||||
"# sheet_count = len(workbook.sheet_names())\n",
|
||||
"\n",
|
||||
"# # 获取所有sheet的名称\n",
|
||||
"# sheet_names = workbook.sheet_names()\n",
|
||||
"\n",
|
||||
"# new_workbook = xlwt.Workbook()\n",
|
||||
"# for i in range(sheet_count):\n",
|
||||
"# # 获取当前sheet\n",
|
||||
"# sheet = workbook.sheet_by_index(i)\n",
|
||||
"\n",
|
||||
"# # 获取sheet的行数和列数\n",
|
||||
"# row_count = sheet.nrows\n",
|
||||
"# col_count = sheet.ncols\n",
|
||||
"# # 获取原有数据\n",
|
||||
"# data = []\n",
|
||||
"# for row in range(row_count):\n",
|
||||
"# row_data = []\n",
|
||||
"# for col in range(col_count):\n",
|
||||
"# row_data.append(sheet.cell_value(row, col))\n",
|
||||
"# data.append(row_data)\n",
|
||||
"\n",
|
||||
"# # 创建xlwt的Workbook对象\n",
|
||||
"# # 创建sheet\n",
|
||||
"# new_sheet = new_workbook.add_sheet(sheet_names[i])\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# current_year_month_row = 0\n",
|
||||
"# # 将原有的数据写入新的sheet\n",
|
||||
"# for row in range(row_count):\n",
|
||||
"# for col in range(col_count):\n",
|
||||
"# col0 = data[row][0]\n",
|
||||
"# # print(\"col0\",col0[:7])\n",
|
||||
"# if col0[:7] == current_year_month:\n",
|
||||
"# current_year_month_row += 1\n",
|
||||
"# break\n",
|
||||
"# new_sheet.write(row, col, data[row][col])\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# # print(\"current_year_month_row\",current_year_month_row)\n",
|
||||
"# if i == 0:\n",
|
||||
"# rowFlag = 0\n",
|
||||
"# # 查看每组数据\n",
|
||||
"# for date, group in grouped:\n",
|
||||
"# new_sheet.write(row_count + rowFlag - current_year_month_row, 0, date)\n",
|
||||
"# for j in range(len(dataItemNoList)):\n",
|
||||
"# dataItemNo = dataItemNoList[j]\n",
|
||||
"\n",
|
||||
"# # for dataItemNo in dataItemNoList:\n",
|
||||
"# if group[group[\"dataItemNo\"] == dataItemNo][\"dataValue\"].values:\n",
|
||||
"\n",
|
||||
"# new_sheet.write(row_count + rowFlag - current_year_month_row, j + 1, group[group[\"dataItemNo\"] == dataItemNo][\"dataValue\"].values[0])\n",
|
||||
"\n",
|
||||
"# rowFlag += 1\n",
|
||||
"\n",
|
||||
"# # 保存新的xls文件\n",
|
||||
"# new_workbook.save(\"液化气数据.xlsx\")\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def queryDataListItemNos(date=None,token=None):\n",
|
||||
" df = pd.read_excel('液化气数据.xls')\n",
|
||||
" df = pd.read_excel('液化气数据.xlsx')\n",
|
||||
" dataItemNoList = df.iloc[0].tolist()[1:]\n",
|
||||
" \n",
|
||||
" if token is None:\n",
|
||||
@ -974,6 +1032,59 @@
|
||||
"\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def start_3(date,token,token_push):\n",
|
||||
" '''预测上传数据'''\n",
|
||||
" read_xls_data()\n",
|
||||
"\n",
|
||||
" # token = get_head_auth()\n",
|
||||
" # if not token:\n",
|
||||
" # return\n",
|
||||
" # token_push = get_head_push_auth()\n",
|
||||
" # if not token_push:\n",
|
||||
" # return\n",
|
||||
"\n",
|
||||
" datas = get_data_value(token, one_cols[1:],date)\n",
|
||||
" if not datas:\n",
|
||||
" return\n",
|
||||
"\n",
|
||||
" # data_list = [two_cols, one_cols]\n",
|
||||
" append_rows = [get_cur_time(date)[1]]\n",
|
||||
" dataItemNo_dataValue = {}\n",
|
||||
" for data_value in datas:\n",
|
||||
" if \"dataValue\" not in data_value:\n",
|
||||
" print(data_value)\n",
|
||||
" dataItemNo_dataValue[data_value[\"dataItemNo\"]] = \"\"\n",
|
||||
" else:\n",
|
||||
" dataItemNo_dataValue[data_value[\"dataItemNo\"]] = data_value[\"dataValue\"]\n",
|
||||
" \n",
|
||||
" for value in one_cols[1:]:\n",
|
||||
" if value in dataItemNo_dataValue:\n",
|
||||
" append_rows.append(dataItemNo_dataValue[value])\n",
|
||||
" else:\n",
|
||||
" append_rows.append(\"\")\n",
|
||||
" save_xlsx(append_rows)\n",
|
||||
"\n",
|
||||
" # 获取当月的数据写入到指定文件\n",
|
||||
" # optimize_Model()\n",
|
||||
" # upload_data_to_system(token_push,date)\n",
|
||||
" # data_list.append(three_cols)\n",
|
||||
" # write_xls(data_list)\n",
|
||||
"\n",
|
||||
"def main(start_date=None,token=None,token_push=None):\n",
|
||||
" if start_date is None:\n",
|
||||
" start_date = datetime.now()\n",
|
||||
" if token is None:\n",
|
||||
" token = get_head_auth()\n",
|
||||
" if token_push is None:\n",
|
||||
" token_push = get_head_push_auth()\n",
|
||||
" date = start_date.strftime('%Y%m%d')\n",
|
||||
" print(date)\n",
|
||||
" # 更新当月数据\n",
|
||||
" queryDataListItemNos(start_date,token)\n",
|
||||
" # 训练模型\n",
|
||||
" optimize_Model()\n",
|
||||
" # 预测&上传预测结果\n",
|
||||
" upload_data_to_system(token_push,start_date)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# if __name__ == \"__main__\":\n",
|
||||
@ -984,7 +1095,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 61,
|
||||
"execution_count": 16,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
@ -1033,48 +1144,147 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 62,
|
||||
"execution_count": 17,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"获取的token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhcGlfZGV2IiwidGgiOiI4YTQ1NzdkYmQ5MTk2NzU3NThkNTc5OTlhMWU4OTFmZSIsImx0IjoiYXBpIiwiaXNzIjoiIiwidG0iOiJQQyIsImV4cCI6MTc0NDEyODI3NywianRpIjoiMjk0MTk4NTU0MWIxNGY2NmJjMTgyY2Y5ZDY1MWVjYzUifQ.2uFevYbViecixxMPgJNCvWO_q2hjzJM35_FavDmEXnI\n"
|
||||
"获取的token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhcGlfZGV2IiwidGgiOiI4YTQ1NzdkYmQ5MTk2NzU3NThkNTc5OTlhMWU4OTFmZSIsImx0IjoiYXBpIiwiaXNzIjoiIiwidG0iOiJQQyIsImV4cCI6MTc0NDE0NDA1MSwianRpIjoiY2MwZTVjOWRkNjFjNDE5YTlkYTc1MDY1ZDNlOGFlN2QifQ.OIWm02tY_o0PjCdNQeQUvHwGNJ6u1SQ5wNGDnDThIx4\n",
|
||||
"20250408\n",
|
||||
" dataDate dataItemNo dataValue\n",
|
||||
"0 2025-04-01 100028046|LISTING_PRICE 8208.0\n",
|
||||
"1 2025-04-02 100028046|LISTING_PRICE 8244.0\n",
|
||||
"2 2025-04-03 100028046|LISTING_PRICE 8244.0\n",
|
||||
"3 2025-04-04 100028046|LISTING_PRICE 8165.0\n",
|
||||
"4 2025-04-05 100028046|LISTING_PRICE 8114.0\n",
|
||||
".. ... ... ...\n",
|
||||
"181 2025-04-07 YHQMXBB|C01100008|STRIKE_PRICE 5180.0\n",
|
||||
"182 2025-04-02 YHQMXBB|C01100008|STRIKE_PRICE 5310.0\n",
|
||||
"183 2025-04-01 YHQMXBB|C01100008|STRIKE_PRICE 5260.0\n",
|
||||
"184 2025-04-04 YHQMXBB|C01100008|STRIKE_PRICE 5230.0\n",
|
||||
"185 2025-04-05 YHQMXBB|C01100008|STRIKE_PRICE 5180.0\n",
|
||||
"\n",
|
||||
"[186 rows x 3 columns]\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ename": "ValueError",
|
||||
"evalue": "Unknown engine: xlwt",
|
||||
"output_type": "error",
|
||||
"traceback": [
|
||||
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
|
||||
"\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)",
|
||||
"Cell \u001b[1;32mIn[62], line 8\u001b[0m\n\u001b[0;32m 6\u001b[0m date \u001b[38;5;241m=\u001b[39m start_date\u001b[38;5;241m.\u001b[39mstrftime(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m%\u001b[39m\u001b[38;5;124mY\u001b[39m\u001b[38;5;124m%\u001b[39m\u001b[38;5;124mm\u001b[39m\u001b[38;5;132;01m%d\u001b[39;00m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m 7\u001b[0m date2 \u001b[38;5;241m=\u001b[39m start_date\u001b[38;5;241m.\u001b[39mstrftime(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m%\u001b[39m\u001b[38;5;124mY-\u001b[39m\u001b[38;5;124m%\u001b[39m\u001b[38;5;124mm-\u001b[39m\u001b[38;5;132;01m%d\u001b[39;00m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m----> 8\u001b[0m updateYesterdayExcelData(date\u001b[38;5;241m=\u001b[39mdate2,token\u001b[38;5;241m=\u001b[39mtoken)\n\u001b[0;32m 9\u001b[0m \u001b[38;5;66;03m# queryDataListItemNos(date=start_date,token=token)\u001b[39;00m\n\u001b[0;32m 10\u001b[0m start(date)\n",
|
||||
"Cell \u001b[1;32mIn[60], line 471\u001b[0m, in \u001b[0;36mupdateYesterdayExcelData\u001b[1;34m(date, token)\u001b[0m\n\u001b[0;32m 469\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mupdateYesterdayExcelData\u001b[39m(date\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m'\u001b[39m, token\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m):\n\u001b[0;32m 470\u001b[0m \u001b[38;5;66;03m# 使用pandas读取Excel文件\u001b[39;00m\n\u001b[1;32m--> 471\u001b[0m df \u001b[38;5;241m=\u001b[39m pd\u001b[38;5;241m.\u001b[39mread_excel(read_file_path_name, engine\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mxlwt\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m 473\u001b[0m \u001b[38;5;66;03m# 获取第二行的数据作为列名\u001b[39;00m\n\u001b[0;32m 474\u001b[0m one_cols \u001b[38;5;241m=\u001b[39m df\u001b[38;5;241m.\u001b[39miloc[\u001b[38;5;241m0\u001b[39m,:]\u001b[38;5;241m.\u001b[39mtolist()\n",
|
||||
"File \u001b[1;32md:\\ProgramData\\anaconda3\\Lib\\site-packages\\pandas\\io\\excel\\_base.py:504\u001b[0m, in \u001b[0;36mread_excel\u001b[1;34m(io, sheet_name, header, names, index_col, usecols, dtype, engine, converters, true_values, false_values, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, parse_dates, date_parser, date_format, thousands, decimal, comment, skipfooter, storage_options, dtype_backend, engine_kwargs)\u001b[0m\n\u001b[0;32m 502\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(io, ExcelFile):\n\u001b[0;32m 503\u001b[0m should_close \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mTrue\u001b[39;00m\n\u001b[1;32m--> 504\u001b[0m io \u001b[38;5;241m=\u001b[39m ExcelFile(\n\u001b[0;32m 505\u001b[0m io,\n\u001b[0;32m 506\u001b[0m storage_options\u001b[38;5;241m=\u001b[39mstorage_options,\n\u001b[0;32m 507\u001b[0m engine\u001b[38;5;241m=\u001b[39mengine,\n\u001b[0;32m 508\u001b[0m engine_kwargs\u001b[38;5;241m=\u001b[39mengine_kwargs,\n\u001b[0;32m 509\u001b[0m )\n\u001b[0;32m 510\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m engine \u001b[38;5;129;01mand\u001b[39;00m engine \u001b[38;5;241m!=\u001b[39m io\u001b[38;5;241m.\u001b[39mengine:\n\u001b[0;32m 511\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[0;32m 512\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mEngine should not be specified when passing \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 513\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124man ExcelFile - ExcelFile already has the engine set\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 514\u001b[0m )\n",
|
||||
"File \u001b[1;32md:\\ProgramData\\anaconda3\\Lib\\site-packages\\pandas\\io\\excel\\_base.py:1531\u001b[0m, in \u001b[0;36mExcelFile.__init__\u001b[1;34m(self, path_or_buffer, engine, storage_options, engine_kwargs)\u001b[0m\n\u001b[0;32m 1528\u001b[0m engine_kwargs \u001b[38;5;241m=\u001b[39m {}\n\u001b[0;32m 1530\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m engine \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;129;01mand\u001b[39;00m engine \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_engines:\n\u001b[1;32m-> 1531\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mUnknown engine: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mengine\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m 1533\u001b[0m \u001b[38;5;66;03m# First argument can also be bytes, so create a buffer\u001b[39;00m\n\u001b[0;32m 1534\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28misinstance\u001b[39m(path_or_buffer, \u001b[38;5;28mbytes\u001b[39m):\n",
|
||||
"\u001b[1;31mValueError\u001b[0m: Unknown engine: xlwt"
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_19260\\847692049.py:890: DeprecationWarning:\n",
|
||||
"\n",
|
||||
"The truth value of an empty array is ambiguous. Returning False, but in future this will result in an error. Use `array.size > 0` to check that an array is not empty.\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"当月数据更新完成\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_19260\\847692049.py:306: UserWarning:\n",
|
||||
"\n",
|
||||
"The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.\n",
|
||||
"\n",
|
||||
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_19260\\847692049.py:308: UserWarning:\n",
|
||||
"\n",
|
||||
"The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.\n",
|
||||
"\n",
|
||||
"d:\\ProgramData\\anaconda3\\Lib\\site-packages\\IPython\\core\\magics\\pylab.py:162: UserWarning:\n",
|
||||
"\n",
|
||||
"pylab import has clobbered these variables: ['random', '__version__', 'plot', 'datetime']\n",
|
||||
"`%matplotlib` prevents importing * from pylab and numpy\n",
|
||||
"\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Using matplotlib backend: QtAgg\n",
|
||||
"%pylab is deprecated, use %matplotlib inline and import the required libraries.\n",
|
||||
"Populating the interactive namespace from numpy and matplotlib\n",
|
||||
"Fitting 3 folds for each of 180 candidates, totalling 540 fits\n",
|
||||
"Date\n",
|
||||
"2025-04-08 5181.777832\n",
|
||||
"Name: 日度预测价格, dtype: float32\n",
|
||||
"预测值: 5181.78\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_19260\\847692049.py:254: UserWarning:\n",
|
||||
"\n",
|
||||
"The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.\n",
|
||||
"\n",
|
||||
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_19260\\847692049.py:256: UserWarning:\n",
|
||||
"\n",
|
||||
"The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.\n",
|
||||
"\n",
|
||||
"C:\\Users\\EDY\\AppData\\Local\\Temp\\ipykernel_19260\\847692049.py:288: FutureWarning:\n",
|
||||
"\n",
|
||||
"Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"start_date = datetime(2025, 4, 2)\n",
|
||||
"end_date = datetime(2025, 4, 3)\n",
|
||||
"token = get_head_auth()\n",
|
||||
"\n",
|
||||
"while start_date < end_date:\n",
|
||||
" date = start_date.strftime('%Y%m%d')\n",
|
||||
" date2 = start_date.strftime('%Y-%m-%d')\n",
|
||||
" updateYesterdayExcelData(date=date2,token=token)\n",
|
||||
" # queryDataListItemNos(date=start_date,token=token)\n",
|
||||
" start(date)\n",
|
||||
" # # time.sleep(1)\n",
|
||||
" # start_1(start_date)\n",
|
||||
" start_date += timedelta(days=1)\n",
|
||||
" time.sleep(5)\n",
|
||||
"if __name__ == \"__main__\":\n",
|
||||
" print(\"运行中ing...\")\n",
|
||||
" # 每天定时12点运行\n",
|
||||
" # while True:\n",
|
||||
" # # 获取当前时间\n",
|
||||
" # current_time = time.strftime(\"%H:%M:%S\", time.localtime())\n",
|
||||
" # try:\n",
|
||||
" # # 判断当前时间是否为执行任务的时间点\n",
|
||||
" # if current_time == \"12:00:00\":\n",
|
||||
" # print(\"执行定时任务\")\n",
|
||||
" # main()\n",
|
||||
" # elif current_time == \"17:45:00\":\n",
|
||||
" # start_1()\n",
|
||||
" # time.sleep(1)\n",
|
||||
" # except:\n",
|
||||
" # print(f\"{current_time}执行失败\")\n",
|
||||
"\n",
|
||||
"# print(price_list)"
|
||||
" start_1()\n",
|
||||
" # 检测数据准确性, 需要检测放开\n",
|
||||
" # check_data(\"100028098|LISTING_PRICE\")\n",
|
||||
" # check_data(\"9137070016544622XB|DAY_Yield\")\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 18,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# start_date = datetime(2025, 4, 2)\n",
|
||||
"# end_date = datetime(2025, 4, 3)\n",
|
||||
"# token = get_head_auth()\n",
|
||||
"\n",
|
||||
"# while start_date < end_date:\n",
|
||||
"# date = start_date.strftime('%Y%m%d')\n",
|
||||
"# date2 = start_date.strftime('%Y-%m-%d')\n",
|
||||
"# queryDataListItemNos(date=start_date,token=token)\n",
|
||||
"# updateYesterdayExcelData(date=date2,token=token)\n",
|
||||
"# start(date)\n",
|
||||
"# # # time.sleep(1)\n",
|
||||
"# # start_1(start_date)\n",
|
||||
"# start_date += timedelta(days=1)\n",
|
||||
"# time.sleep(5)\n",
|
||||
"\n",
|
||||
"# # print(price_list)"
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -1087,7 +1297,7 @@
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "base",
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
|
BIN
aisenzhecode/液化石油气/液化气数据 - 副本.xls
Normal file
BIN
aisenzhecode/液化石油气/液化气数据 - 副本.xls
Normal file
Binary file not shown.
BIN
aisenzhecode/液化石油气/液化气数据.xlsx
Normal file
BIN
aisenzhecode/液化石油气/液化气数据.xlsx
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user