{
 "cells": [
  {
   "metadata": {},
   "cell_type": "markdown",
   "source": "",
   "id": "e15a8efa2c7f6fbb"
  },
  {
   "cell_type": "code",
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-06-09T02:46:42.144470Z",
     "start_time": "2025-06-09T02:46:39.807726Z"
    }
   },
   "source": [
    "import pandas as pd\n",
    "\n",
    "df = pd.read_excel(r\"C:\\Users\\Administrator.DESKTOP-7IC2USJ\\Downloads\\日常回访表_20250609104426.xlsx\",sheet_name=\"Sheet1\")\n",
    "\n",
    "# 放删除的数据\n",
    "re_list = []  # 放重复数据的门店编码\n",
    "re_list2  = [] # 放保留数据的门店编码\n",
    "# re_list3 = [] # 放有修改过的门店编码\n",
    "\n",
    "delete_list = [] # 放删除的data_id\n",
    "\n",
    "\n",
    "all_data_list = []\n",
    "for index, row in df.iterrows():\n",
    "    if row[\"门店编码\"] not in re_list:\n",
    "        # re_list.append(row[\"门店编码\"])\n",
    "        \n",
    "        if row[\"提交时间\"] == row[\"更新时间\"]:\n",
    "            re_list.append(row[\"门店编码\"])\n",
    "            delete_list.append(row[\"data_id\"])\n",
    "            \n",
    "            all_data_list.append(dict(row) | {\"池子\":\"删除\"})\n",
    "        else:\n",
    "            re_list2.append(row[\"门店编码\"])\n",
    "            all_data_list.append(dict(row) | {\"池子\":\"保留\"})\n",
    "    else:\n",
    "        \n",
    "        if row[\"门店编码\"] in re_list2 and row[\"提交时间\"] == row[\"更新时间\"]:\n",
    "            re_list.append(row[\"门店编码\"])\n",
    "            delete_list.append(row[\"data_id\"])\n",
    "            all_data_list.append(dict(row) | {\"池子\":\"删除\"})\n",
    "        else:\n",
    "            re_list2.append(row[\"门店编码\"])\n",
    "            all_data_list.append(dict(row) | {\"池子\":\"保留\"})\n",
    "\n",
    "df2 = pd.DataFrame(all_data_list)\n",
    "df2.to_excel(\"./result.xlsx\")\n",
    "            \n"
   ],
   "outputs": [],
   "execution_count": 1
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
