{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "8acf2361-ac67-430c-a0d8-db6e5bd64407",
   "metadata": {},
   "source": [
    "# Manual Delete"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "7e0ac6d7-03a1-4b83-8c11-9b097086a22d",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Open the text file for reading\n",
    "with open('2.txt', 'r') as file:\n",
    "    # Split the data using comma as a delimiter and convert to a list\n",
    "    data = [line.strip().split(',') for line in file]\n",
    "\n",
    "# Delete rows where the second column value is 17 and the first column value is less than 6630\n",
    "data = [row for row in data if not (row[1] == '131' and int(row[0]) < 52496)]\n",
    "# data = [row for row in data if not (row[1] == '136' and int(row[0]) < 8302)]\n",
    "# data = [row for row in data if not (row[1] == '152' and int(row[0]) < 9447)]\n",
    "# data = [row for row in data if not (row[1] == '174' and int(row[0]) < 10980)]\n",
    "# data = [row for row in data if not (row[1] == '175' and int(row[0]) < 11191)]\n",
    "# data = [row for row in data if not (row[1] == '237' and int(row[0]) < 16215)]\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "data = [row for row in data if not (row[1] in ['13', '98','113'])]\n",
    "# data = [row for row in data if not (row[1] == '14')]\n",
    "# Open a new file for writing\n",
    "with open('c002-new.txt', 'w') as file:\n",
    "    # Write each row of data to the file, separated by comma\n",
    "    for row in data:\n",
    "        file.write(','.join(row) + '\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3e90d06b-8517-416a-ab31-b98f8fabeb61",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "0d514bf8-3374-42ae-9de7-1f2500614f82",
   "metadata": {},
   "outputs": [],
   "source": [
    "input_file = \"c002.txt\"\n",
    "output_file = \"2.txt\"\n",
    "\n",
    "with open(input_file, \"r\") as infile, open(output_file, \"w\") as outfile:\n",
    "    for line in infile:\n",
    "        columns = line.strip().split(\",\")\n",
    "        \n",
    "        if int(columns[1]) == 36 and 7600 < int(columns[0]):\n",
    "            columns[1] = \"1\"\n",
    "            \n",
    "        if int(columns[1]) == 1 and 7600 < int(columns[0]):\n",
    "            columns[1] = \"36\"\n",
    "            \n",
    "        if int(columns[1]) == 88 and 19129 < int(columns[0]):\n",
    "            columns[1] = \"93\"\n",
    "            \n",
    "        if int(columns[1]) == 93 and 19129 < int(columns[0]):\n",
    "            columns[1] = \"88\"\n",
    "            \n",
    "        if int(columns[1]) == 97 and 20654 < int(columns[0]):\n",
    "            columns[1] = \"90\"\n",
    "            \n",
    "        if int(columns[1]) == 90 and 20654 < int(columns[0]):\n",
    "            columns[1] = \"97\"\n",
    "            \n",
    "       \n",
    "            \n",
    "        \n",
    "        \n",
    "            \n",
    "        new_line = \",\".join(columns)\n",
    "        \n",
    "        \n",
    "        \n",
    "        outfile.write(new_line + \"\\n\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a876a4d9-3bdc-4f26-8a4b-6c4d1d5c4155",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "torch190-test",
   "language": "python",
   "name": "torch190-test"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
