├── Advance Text Preprocessing ├── Advance Text Preprocessing.ipynb └── data.txt ├── Inventory Management System - Conclusion ├── Inventory Management System - Conclusion.ipynb ├── Inventory.txt └── Sales.txt ├── Inventory Management System - Generating Bill └── Inventory Management System - Generating Bill.ipynb ├── Inventory Management System - JSON Overview └── Inventory Management System - JSON Overview.ipynb ├── Inventory Management System JSON - Adding Functionalities ├── Inventory Management System - Adding Functionalities.ipynb └── Record.json ├── Inventory Management System JSON - Conclusion ├── Inventory Management System - Conclusion.ipynb ├── Record.json ├── Sales.csv └── Sales.txt ├── Inventory Management System JSON - Generating Sales Structure ├── Inventory Management System - Generating Sales Structure.ipynb └── Record.json ├── Inventory Management System JSON - Generating Sales file ├── Inventory Management System - Generating Sales file.ipynb ├── Record.json ├── Sales.csv └── Sales.txt ├── Inventory Management System JSON - Saving Record ├── Inventory Management System - Saving Record on JSON.ipynb └── Record.json ├── Inventory Management System JSON - Updating Inventory └── Inventory Management System - Updating Inventory.ipynb ├── Inventory Management System JSON- Loading Record ├── Inventory Management System - Loading Record from JSON.ipynb └── Record.json ├── Inventory Management with Files - Add Functionalities ├── Inventory Management with Files - Add Functionalities.ipynb └── Inventory.txt ├── Inventory Management with Files - Generate Sales ├── Inventory Management with Files - Generate Sales.ipynb ├── Inventory.txt └── Sales.txt ├── Inventory Management with Files - Overview ├── Inventory Management - Overview.ipynb └── Inventory.txt ├── Inventory Management with Files - Product Details ├── Inventory Management with Files - Product Details.ipynb └── Inventory.txt ├── Inventory Management with Files - Updating Inventory ├── Inventory Management with Files - Updating Inventory.ipynb └── Inventory.txt ├── LICENSE ├── README.md ├── Reading Data from File ├── Reading Data from File.ipynb └── data.txt ├── Reading Data from Text-file Corpus ├── Reading Data from Text-file Corpus.ipynb └── data.txt ├── Text Preprocessing ├── Text Preprocessing.ipynb └── data.txt ├── Writing Data on a text-file with New Line ├── Data.txt └── Writing Data on a text-file with New Line.ipynb └── Writing Data on a text-file ├── Data.txt └── Writing Data on a text-file.ipynb /Advance Text Preprocessing/Advance Text Preprocessing.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 46, 6 | "id": "cdbe1e43", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "fd = open('data.txt','r')\n", 11 | "txt = fd.read()\n", 12 | "fd.close()" 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": 47, 18 | "id": "f3e1d7eb", 19 | "metadata": {}, 20 | "outputs": [ 21 | { 22 | "data": { 23 | "text/plain": [ 24 | "\"Coronavirus disease 2019 (COVID-19) is a contagious disease caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2). The first known case was identified in Wuhan, China, in December 2019.[7] The disease has since spread worldwide, leading to an ongoing pandemic.[8]\\n\\nSymptoms of COVID-19 are variable, but often include fever,[9] cough, headache,[10] fatigue, breathing difficulties, and loss of smell and taste.[11][12][13] Symptoms may begin one to fourteen days after exposure to the virus. At least a third of people who are infected do not develop noticeable symptoms.[14] Of those people who develop symptoms noticeable enough to be classed as patients, most (81%) develop mild to moderate symptoms (up to mild pneumonia), while 14% develop severe symptoms (dyspnea, hypoxia, or more than 50% lung involvement on imaging), and 5% suffer critical symptoms (respiratory failure, shock, or multi-organ dysfunction).[15] Older people are at a higher risk of developing severe symptoms. Some people continue to experience a range of effects (long COVID) for months after recovery, and damage to organs has been observed.[16] Multi-year studies are underway to further investigate the long-term effects of the disease.[16]\\n\\nCOVID-19 transmits when people breathe in air contaminated by droplets and small airborne particles containing the virus. The risk of breathing these in is highest when people are in close proximity, but they can be inhaled over longer distances, particularly indoors. Transmission can also occur if splashed or sprayed with contaminated fluids in the eyes, nose or mouth, and, rarely, via contaminated surfaces. People remain contagious for up to 20 days, and can spread the virus even if they do not develop symptoms.[17][18]\\n\\nSeveral testing methods have been developed to diagnose the disease. The standard diagnostic method is by detection of the virus' nucleic acid by real-time reverse transcription polymerase chain reaction (rRT-PCR), transcription-mediated amplification (TMA), or by reverse transcription loop-mediated isothermal amplification (RT-LAMP) from a nasopharyngeal swab.\\n\\nPreventive measures include physical or social distancing, quarantining, ventilation of indoor spaces, covering coughs and sneezes, hand washing, and keeping unwashed hands away from the face. The use of face masks or coverings has been recommended in public settings to minimise the risk of transmissions.\\n\\nWhile work is underway to develop drugs that inhibit the virus (and several vaccines for it have been approved and distributed in various countries, which have since initiated mass vaccination campaigns), the primary treatment is symptomatic. Management involves the treatment of symptoms, supportive care, isolation, and experimental measures.\"" 25 | ] 26 | }, 27 | "execution_count": 47, 28 | "metadata": {}, 29 | "output_type": "execute_result" 30 | } 31 | ], 32 | "source": [ 33 | "txt" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": 57, 39 | "id": "2b200957", 40 | "metadata": { 41 | "scrolled": true 42 | }, 43 | "outputs": [], 44 | "source": [ 45 | "for i in range(7,19):\n", 46 | " pattern = \"[\" + str(i) + \"]\"\n", 47 | " txt = txt.replace(pattern , \"\")" 48 | ] 49 | }, 50 | { 51 | "cell_type": "code", 52 | "execution_count": 59, 53 | "id": "3e3524ac", 54 | "metadata": {}, 55 | "outputs": [ 56 | { 57 | "name": "stdout", 58 | "output_type": "stream", 59 | "text": [ 60 | "Coronavirus disease 2019 (COVID-19) is a contagious disease caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2). The first known case was identified in Wuhan, China, in December 2019. The disease has since spread worldwide, leading to an ongoing pandemic.\n", 61 | "\n", 62 | "Symptoms of COVID-19 are variable, but often include fever, cough, headache, fatigue, breathing difficulties, and loss of smell and taste. Symptoms may begin one to fourteen days after exposure to the virus. At least a third of people who are infected do not develop noticeable symptoms. Of those people who develop symptoms noticeable enough to be classed as patients, most (81%) develop mild to moderate symptoms (up to mild pneumonia), while 14% develop severe symptoms (dyspnea, hypoxia, or more than 50% lung involvement on imaging), and 5% suffer critical symptoms (respiratory failure, shock, or multi-organ dysfunction). Older people are at a higher risk of developing severe symptoms. Some people continue to experience a range of effects (long COVID) for months after recovery, and damage to organs has been observed. Multi-year studies are underway to further investigate the long-term effects of the disease.\n", 63 | "\n", 64 | "COVID-19 transmits when people breathe in air contaminated by droplets and small airborne particles containing the virus. The risk of breathing these in is highest when people are in close proximity, but they can be inhaled over longer distances, particularly indoors. Transmission can also occur if splashed or sprayed with contaminated fluids in the eyes, nose or mouth, and, rarely, via contaminated surfaces. People remain contagious for up to 20 days, and can spread the virus even if they do not develop symptoms.\n", 65 | "\n", 66 | "Several testing methods have been developed to diagnose the disease. The standard diagnostic method is by detection of the virus' nucleic acid by real-time reverse transcription polymerase chain reaction (rRT-PCR), transcription-mediated amplification (TMA), or by reverse transcription loop-mediated isothermal amplification (RT-LAMP) from a nasopharyngeal swab.\n", 67 | "\n", 68 | "Preventive measures include physical or social distancing, quarantining, ventilation of indoor spaces, covering coughs and sneezes, hand washing, and keeping unwashed hands away from the face. The use of face masks or coverings has been recommended in public settings to minimise the risk of transmissions.\n", 69 | "\n", 70 | "While work is underway to develop drugs that inhibit the virus (and several vaccines for it have been approved and distributed in various countries, which have since initiated mass vaccination campaigns), the primary treatment is symptomatic. Management involves the treatment of symptoms, supportive care, isolation, and experimental measures.\n" 71 | ] 72 | } 73 | ], 74 | "source": [ 75 | "print(txt)" 76 | ] 77 | }, 78 | { 79 | "cell_type": "code", 80 | "execution_count": null, 81 | "id": "1ae8fdd8", 82 | "metadata": {}, 83 | "outputs": [], 84 | "source": [ 85 | "for i in \"!@#$%^\":\n", 86 | " txt = txt.replace(i , \"\")" 87 | ] 88 | } 89 | ], 90 | "metadata": { 91 | "kernelspec": { 92 | "display_name": "Python 3", 93 | "language": "python", 94 | "name": "python3" 95 | }, 96 | "language_info": { 97 | "codemirror_mode": { 98 | "name": "ipython", 99 | "version": 3 100 | }, 101 | "file_extension": ".py", 102 | "mimetype": "text/x-python", 103 | "name": "python", 104 | "nbconvert_exporter": "python", 105 | "pygments_lexer": "ipython3", 106 | "version": "3.8.8" 107 | } 108 | }, 109 | "nbformat": 4, 110 | "nbformat_minor": 5 111 | } 112 | -------------------------------------------------------------------------------- /Advance Text Preprocessing/data.txt: -------------------------------------------------------------------------------- 1 | Coronavirus disease 2019 (COVID-19) is a contagious disease caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2). The first known case was identified in Wuhan, China, in December 2019.[7] The disease has since spread worldwide, leading to an ongoing pandemic.[8] 2 | 3 | Symptoms of COVID-19 are variable, but often include fever,[9] cough, headache,[10] fatigue, breathing difficulties, and loss of smell and taste.[11][12][13] Symptoms may begin one to fourteen days after exposure to the virus. At least a third of people who are infected do not develop noticeable symptoms.[14] Of those people who develop symptoms noticeable enough to be classed as patients, most (81%) develop mild to moderate symptoms (up to mild pneumonia), while 14% develop severe symptoms (dyspnea, hypoxia, or more than 50% lung involvement on imaging), and 5% suffer critical symptoms (respiratory failure, shock, or multi-organ dysfunction).[15] Older people are at a higher risk of developing severe symptoms. Some people continue to experience a range of effects (long COVID) for months after recovery, and damage to organs has been observed.[16] Multi-year studies are underway to further investigate the long-term effects of the disease.[16] 4 | 5 | COVID-19 transmits when people breathe in air contaminated by droplets and small airborne particles containing the virus. The risk of breathing these in is highest when people are in close proximity, but they can be inhaled over longer distances, particularly indoors. Transmission can also occur if splashed or sprayed with contaminated fluids in the eyes, nose or mouth, and, rarely, via contaminated surfaces. People remain contagious for up to 20 days, and can spread the virus even if they do not develop symptoms.[17][18] 6 | 7 | Several testing methods have been developed to diagnose the disease. The standard diagnostic method is by detection of the virus' nucleic acid by real-time reverse transcription polymerase chain reaction (rRT-PCR), transcription-mediated amplification (TMA), or by reverse transcription loop-mediated isothermal amplification (RT-LAMP) from a nasopharyngeal swab. 8 | 9 | Preventive measures include physical or social distancing, quarantining, ventilation of indoor spaces, covering coughs and sneezes, hand washing, and keeping unwashed hands away from the face. The use of face masks or coverings has been recommended in public settings to minimise the risk of transmissions. 10 | 11 | While work is underway to develop drugs that inhibit the virus (and several vaccines for it have been approved and distributed in various countries, which have since initiated mass vaccination campaigns), the primary treatment is symptomatic. Management involves the treatment of symptoms, supportive care, isolation, and experimental measures. -------------------------------------------------------------------------------- /Inventory Management System - Conclusion/Inventory Management System - Conclusion.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "7090ccd4", 6 | "metadata": {}, 7 | "source": [ 8 | "## Product Details\n", 9 | "1. Product ID\n", 10 | "2. Name of Product\n", 11 | "3. Price of Product\n", 12 | "4. Quantity" 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": 23, 18 | "id": "e189d341", 19 | "metadata": { 20 | "scrolled": true 21 | }, 22 | "outputs": [ 23 | { 24 | "name": "stdout", 25 | "output_type": "stream", 26 | "text": [ 27 | "Enter your Name: Ashish\n", 28 | "Enter your Phone No: 432423\n", 29 | "Enter your Mail: dsfds@mgaifs.com\n", 30 | "Enter product ID: 3\n", 31 | "Enter product Quantity: 10\n", 32 | "Sorry, We're not having enought quantity.\n", 33 | "We're having only 8 quantity.\n", 34 | "Would you like to purchase it?\n", 35 | "Press Y/N: Y\n", 36 | "-----------------------------\n", 37 | "Product Name : Cake\n", 38 | "Price : 300\n", 39 | "Quantity : 8\n", 40 | "-----------------------------\n", 41 | "Billing Amount : 2400\n", 42 | "-----------------------------\n", 43 | "Inventory Updated\n" 44 | ] 45 | } 46 | ], 47 | "source": [ 48 | "# Noting the time of trasection\n", 49 | "import time\n", 50 | "\n", 51 | "# Reading the Inventory\n", 52 | "fd = open('Inventory.txt','r') \n", 53 | "products = fd.read().split('\\n')\n", 54 | "fd.close()\n", 55 | "\n", 56 | "# Taking User Input\n", 57 | "ui_username = input(\"Enter your Name: \")\n", 58 | "ui_phone = input(\"Enter your Phone No: \")\n", 59 | "ui_mail = input(\"Enter your Mail: \")\n", 60 | "ui_prod_id = input(\"Enter product ID: \")\n", 61 | "ui_prod_qn = input(\"Enter product Quantity: \")\n", 62 | "\n", 63 | "updated_product_lst = []\n", 64 | "\n", 65 | "# Going through each product detail\n", 66 | "for product in products:\n", 67 | " prod_details = product.split(',')\n", 68 | " if(prod_details[0] == ui_prod_id):\n", 69 | " # Checking if product exists or not\n", 70 | "\n", 71 | " if (int(ui_prod_qn) <= int(prod_details[3])):\n", 72 | " # If we're having enough quantity\n", 73 | " \n", 74 | " print(\"-----------------------------\")\n", 75 | " print(\"Product Name : \", prod_details[1])\n", 76 | " print(\"Price : \", prod_details[2]) \n", 77 | " print(\"Quantity : \", ui_prod_qn) \n", 78 | " print(\"-----------------------------\")\n", 79 | " print(\"Billing Amount : \", int(ui_prod_qn) * int(prod_details[2]))\n", 80 | " print(\"-----------------------------\")\n", 81 | "\n", 82 | " # Updating Inventory list\n", 83 | " prod_details[3] = str(int(prod_details[3]) - int(ui_prod_qn))\n", 84 | " \n", 85 | " # Generating Sales in Sales.txt\n", 86 | " fd = open(\"Sales.txt\",'a')\n", 87 | " sales_detail = ui_username +\",\"+ ui_phone +\",\"+ ui_mail +\",\"+prod_details[1] +\",\"+ ui_prod_id +\",\"+ ui_prod_qn +\",\"+ str(int(ui_prod_qn) * int(prod_details[2]))+\",\"+time.ctime()+ \"\\n\"\n", 88 | " fd.write(sales_detail)\n", 89 | " fd.close()\n", 90 | " \n", 91 | " else:\n", 92 | " # If we're not having enough quantity\n", 93 | " \n", 94 | " print(\"Sorry, We're not having enought quantity.\")\n", 95 | " print(\"We're having only\",prod_details[3],'quantity.')\n", 96 | " print(\"Would you like to purchase it?\")\n", 97 | " \n", 98 | " ch = input(\"Press Y/N: \")\n", 99 | " \n", 100 | " if (ch == 'Y' or ch == 'y'):\n", 101 | " # If you want to purchase with remaining quantity\n", 102 | " \n", 103 | " print(\"-----------------------------\")\n", 104 | " print(\"Product Name : \", prod_details[1])\n", 105 | " print(\"Price : \", prod_details[2]) \n", 106 | " print(\"Quantity : \", prod_details[3]) \n", 107 | " print(\"-----------------------------\")\n", 108 | " print(\"Billing Amount : \", int(prod_details[3]) * int(prod_details[2]))\n", 109 | " print(\"-----------------------------\")\n", 110 | " \n", 111 | " # Generating Sales in Sales.txt\n", 112 | " fd = open(\"Sales.txt\",'a')\n", 113 | " sales_detail = ui_username +\",\"+ ui_phone +\",\"+ ui_mail +\",\"+prod_details[1] +\",\"+ ui_prod_id +\",\"+ prod_details[3] +\",\"+ str(int(prod_details[3]) * int(prod_details[2]))+\",\"+time.ctime()+ \"\\n\"\n", 114 | " fd.write(sales_detail)\n", 115 | " fd.close()\n", 116 | " \n", 117 | " # Updating Inventory list\n", 118 | " prod_details[3] = '0'\n", 119 | "\n", 120 | " else:\n", 121 | " print(\"Thanks\")\n", 122 | " \n", 123 | " # Updating my Inventory List\n", 124 | " updated_product_lst.append(prod_details)\n", 125 | " \n", 126 | "\n", 127 | " \n", 128 | "lst = []\n", 129 | "\n", 130 | "# Updating my Inventory String\n", 131 | "for i in updated_product_lst:\n", 132 | " prod = i[0] +\",\"+ i[1] +\",\"+ i[2] +\",\"+ i[3] + '\\n'\n", 133 | " lst.append(prod)\n", 134 | "\n", 135 | "# Removing Last \\n from the list\n", 136 | "lst[-1] = lst[-1][:-1]\n", 137 | " \n", 138 | "\n", 139 | "# Updating Inventory File\n", 140 | "fd = open('Inventory.txt','w')\n", 141 | "\n", 142 | "for i in lst:\n", 143 | " fd.write(i)\n", 144 | "fd.close()\n", 145 | "\n", 146 | "print(\"Inventory Updated\")" 147 | ] 148 | }, 149 | { 150 | "cell_type": "code", 151 | "execution_count": null, 152 | "id": "c148d838", 153 | "metadata": {}, 154 | "outputs": [], 155 | "source": [] 156 | } 157 | ], 158 | "metadata": { 159 | "kernelspec": { 160 | "display_name": "Python 3", 161 | "language": "python", 162 | "name": "python3" 163 | }, 164 | "language_info": { 165 | "codemirror_mode": { 166 | "name": "ipython", 167 | "version": 3 168 | }, 169 | "file_extension": ".py", 170 | "mimetype": "text/x-python", 171 | "name": "python", 172 | "nbconvert_exporter": "python", 173 | "pygments_lexer": "ipython3", 174 | "version": "3.8.8" 175 | } 176 | }, 177 | "nbformat": 4, 178 | "nbformat_minor": 5 179 | } 180 | -------------------------------------------------------------------------------- /Inventory Management System - Conclusion/Inventory.txt: -------------------------------------------------------------------------------- 1 | 1,5 Star,5,98 2 | 2,Milky Bar,5,195 3 | 3,Cake,300,0 4 | 4,Candy,1,1000 -------------------------------------------------------------------------------- /Inventory Management System - Conclusion/Sales.txt: -------------------------------------------------------------------------------- 1 | Ahsihs,4,324,Cake,3,2,600,Tue Sep 21 02:12:25 2021 2 | Ashish,7382947328,abc@gmail.com,Cake,3,0,0,Tue Sep 21 02:27:21 2021 3 | Ashish,432423,dsfds@mgaifs.com,Cake,3,8,2400,Tue Sep 21 02:29:11 2021 4 | -------------------------------------------------------------------------------- /Inventory Management System - Generating Bill/Inventory Management System - Generating Bill.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 4, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "record = {1001: {'Name': \"5 Star\" , \"Price\" : 10 , \"Qn\" : 200},\n", 10 | " 1002: {'Name': \"Bar-One\" , \"Price\" : 20 , \"Qn\" : 100 },\n", 11 | " 1003: {'Name': \"Candy\" , \"Price\" : 2 , \"Qn\" : 1000},\n", 12 | " 1004: {'Name': \"Chocolate Cake\" , \"Price\" : 550, \"Qn\" : 8 },\n", 13 | " 1005: {'Name': \"Blueberry Cake\" , \"Price\" : 650, \"Qn\" : 5 }}" 14 | ] 15 | }, 16 | { 17 | "cell_type": "code", 18 | "execution_count": 5, 19 | "metadata": {}, 20 | "outputs": [ 21 | { 22 | "data": { 23 | "text/plain": [ 24 | "{1001: {'Name': '5 Star', 'Price': 10, 'Qn': 200},\n", 25 | " 1002: {'Name': 'Bar-One', 'Price': 20, 'Qn': 100},\n", 26 | " 1003: {'Name': 'Candy', 'Price': 2, 'Qn': 1000},\n", 27 | " 1004: {'Name': 'Chocolate Cake', 'Price': 550, 'Qn': 8},\n", 28 | " 1005: {'Name': 'Blueberry Cake', 'Price': 650, 'Qn': 5}}" 29 | ] 30 | }, 31 | "execution_count": 5, 32 | "metadata": {}, 33 | "output_type": "execute_result" 34 | } 35 | ], 36 | "source": [ 37 | "record" 38 | ] 39 | }, 40 | { 41 | "cell_type": "code", 42 | "execution_count": 33, 43 | "metadata": {}, 44 | "outputs": [ 45 | { 46 | "name": "stdout", 47 | "output_type": "stream", 48 | "text": [ 49 | "--------------------MENU---------------------\n", 50 | "(1001, '5 Star', 10, '5 Star')\n", 51 | "(1002, 'Bar-One', 20, 'Bar-One')\n", 52 | "(1003, 'Candy', 2, 'Candy')\n", 53 | "(1004, 'Chocolate Cake', 550, 'Chocolate Cake')\n", 54 | "(1005, 'Blueberry Cake', 650, 'Blueberry Cake')\n", 55 | "---------------------------------------------\n", 56 | "\n", 57 | "Enter product ID : 1005\n", 58 | "Enter Quantiry : 1\n", 59 | "---------------------------------------------\n", 60 | "\n", 61 | "('Name : ', 'Blueberry Cake')\n", 62 | "('Price (Rs): ', 650)\n", 63 | "('Quantity : ', 1)\n", 64 | "---------------------------------------------\n", 65 | "('Billing : ', 650, 'Rs')\n", 66 | "---------------------------------------------\n" 67 | ] 68 | } 69 | ], 70 | "source": [ 71 | "print(\"--------------------MENU---------------------\")\n", 72 | "for key in record.keys():\n", 73 | " print(key, record[key]['Name'], record[key]['Price'], record[key]['Name'])\n", 74 | "print(\"---------------------------------------------\")\n", 75 | "print('')\n", 76 | "\n", 77 | "ui_pr = int(input(\"Enter product ID : \"))\n", 78 | "ui_qn = int(input(\"Enter Quantiry : \"))\n", 79 | "\n", 80 | "print(\"---------------------------------------------\")\n", 81 | "print('')\n", 82 | "\n", 83 | "print(\"Name : \", record[ui_pr][\"Name\"])\n", 84 | "print(\"Price (Rs): \", record[ui_pr][\"Price\"])\n", 85 | "print(\"Quantity : \", ui_qn)\n", 86 | "print(\"---------------------------------------------\")\n", 87 | "print(\"Billing : \", ui_qn * record[ui_pr][\"Price\"], \"Rs\")\n", 88 | "print(\"---------------------------------------------\")" 89 | ] 90 | }, 91 | { 92 | "cell_type": "code", 93 | "execution_count": 34, 94 | "metadata": {}, 95 | "outputs": [ 96 | { 97 | "data": { 98 | "text/plain": [ 99 | "{1001: {'Name': '5 Star', 'Price': 10, 'Qn': 200},\n", 100 | " 1002: {'Name': 'Bar-One', 'Price': 20, 'Qn': 100},\n", 101 | " 1003: {'Name': 'Candy', 'Price': 2, 'Qn': 1000},\n", 102 | " 1004: {'Name': 'Chocolate Cake', 'Price': 550, 'Qn': 8},\n", 103 | " 1005: {'Name': 'Blueberry Cake', 'Price': 650, 'Qn': 5}}" 104 | ] 105 | }, 106 | "execution_count": 34, 107 | "metadata": {}, 108 | "output_type": "execute_result" 109 | } 110 | ], 111 | "source": [ 112 | "record" 113 | ] 114 | } 115 | ], 116 | "metadata": { 117 | "kernelspec": { 118 | "display_name": "Python 2", 119 | "language": "python", 120 | "name": "python2" 121 | }, 122 | "language_info": { 123 | "codemirror_mode": { 124 | "name": "ipython", 125 | "version": 2 126 | }, 127 | "file_extension": ".py", 128 | "mimetype": "text/x-python", 129 | "name": "python", 130 | "nbconvert_exporter": "python", 131 | "pygments_lexer": "ipython2", 132 | "version": "2.7.16" 133 | } 134 | }, 135 | "nbformat": 4, 136 | "nbformat_minor": 2 137 | } 138 | -------------------------------------------------------------------------------- /Inventory Management System - JSON Overview/Inventory Management System - JSON Overview.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 4, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "record = {1001: {'Name': \"5 Star\" , \"Price\" : 10 , \"Qn\" : 200},\n", 10 | " 1002: {'Name': \"Bar-One\" , \"Price\" : 20 , \"Qn\" : 100 },\n", 11 | " 1003: {'Name': \"Candy\" , \"Price\" : 2 , \"Qn\" : 1000},\n", 12 | " 1004: {'Name': \"Chocolate Cake\" , \"Price\" : 550, \"Qn\" : 8 },\n", 13 | " 1005: {'Name': \"Blueberry Cake\" , \"Price\" : 650, \"Qn\" : 5 }}" 14 | ] 15 | }, 16 | { 17 | "cell_type": "code", 18 | "execution_count": 5, 19 | "metadata": {}, 20 | "outputs": [ 21 | { 22 | "data": { 23 | "text/plain": [ 24 | "{1001: {'Name': '5 Star', 'Price': 10, 'Qn': 200},\n", 25 | " 1002: {'Name': 'Bar-One', 'Price': 20, 'Qn': 100},\n", 26 | " 1003: {'Name': 'Candy', 'Price': 2, 'Qn': 1000},\n", 27 | " 1004: {'Name': 'Chocolate Cake', 'Price': 550, 'Qn': 8},\n", 28 | " 1005: {'Name': 'Blueberry Cake', 'Price': 650, 'Qn': 5}}" 29 | ] 30 | }, 31 | "execution_count": 5, 32 | "metadata": {}, 33 | "output_type": "execute_result" 34 | } 35 | ], 36 | "source": [ 37 | "record" 38 | ] 39 | }, 40 | { 41 | "cell_type": "code", 42 | "execution_count": 11, 43 | "metadata": {}, 44 | "outputs": [ 45 | { 46 | "name": "stdout", 47 | "output_type": "stream", 48 | "text": [ 49 | "Chocolate Cake\n", 50 | "550\n", 51 | "8\n" 52 | ] 53 | } 54 | ], 55 | "source": [ 56 | "print(record[1004][\"Name\"])\n", 57 | "print(record[1004][\"Price\"])\n", 58 | "print(record[1004][\"Qn\"])" 59 | ] 60 | }, 61 | { 62 | "cell_type": "code", 63 | "execution_count": null, 64 | "metadata": {}, 65 | "outputs": [], 66 | "source": [] 67 | } 68 | ], 69 | "metadata": { 70 | "kernelspec": { 71 | "display_name": "Python 2", 72 | "language": "python", 73 | "name": "python2" 74 | }, 75 | "language_info": { 76 | "codemirror_mode": { 77 | "name": "ipython", 78 | "version": 2 79 | }, 80 | "file_extension": ".py", 81 | "mimetype": "text/x-python", 82 | "name": "python", 83 | "nbconvert_exporter": "python", 84 | "pygments_lexer": "ipython2", 85 | "version": "2.7.16" 86 | } 87 | }, 88 | "nbformat": 4, 89 | "nbformat_minor": 2 90 | } 91 | -------------------------------------------------------------------------------- /Inventory Management System JSON - Adding Functionalities/Inventory Management System - Adding Functionalities.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 17, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "--------------------MENU---------------------\n", 13 | "(u'1005', u'Blueberry Cake', 650, 0)\n", 14 | "(u'1004', u'Chocolate Cake', 550, 8)\n", 15 | "(u'1003', u'Candy', 2, 950)\n", 16 | "(u'1002', u'Bar-One', 20, 95)\n", 17 | "(u'1001', u'5 Star', 10, 195)\n", 18 | "---------------------------------------------\n", 19 | "\n", 20 | "Enter product ID : 1004\n", 21 | "Enter Quantiry : 10\n", 22 | "---------------------------------------------\n", 23 | "\n", 24 | "Sorry, We're not having enough quanity of product in our Inventory.\n", 25 | "We're only having 8 quantity.\n", 26 | "---------------------------------------------\n", 27 | "Press Y to purchase: Y\n", 28 | "---------------------------------------------\n", 29 | "('Name : ', u'Chocolate Cake')\n", 30 | "('Price (Rs): ', 550)\n", 31 | "('Quantity : ', 8)\n", 32 | "---------------------------------------------\n", 33 | "('Billing : ', 4400, 'Rs')\n", 34 | "---------------------------------------------\n", 35 | "\n", 36 | "---------------------------------------------\n", 37 | " Thanks for your order, Inventory Updated! \n", 38 | "---------------------------------------------\n" 39 | ] 40 | } 41 | ], 42 | "source": [ 43 | "import json\n", 44 | "\n", 45 | "ch = 'Y'\n", 46 | "fd = open('Record.json','r')\n", 47 | "js = fd.read()\n", 48 | "fd.close()\n", 49 | "\n", 50 | "record = json.loads(js)\n", 51 | "\n", 52 | "print(\"--------------------MENU---------------------\")\n", 53 | "for key in record.keys():\n", 54 | " print(key, record[key]['Name'], record[key]['Price'], record[key]['Qn'])\n", 55 | "print(\"---------------------------------------------\")\n", 56 | "print('')\n", 57 | "\n", 58 | "ui_pr = str(input(\"Enter product ID : \"))\n", 59 | "ui_qn = int(input(\"Enter Quantiry : \"))\n", 60 | "\n", 61 | "print(\"---------------------------------------------\")\n", 62 | "print('')\n", 63 | "\n", 64 | "if (record[ui_pr]['Qn'] >= ui_qn):\n", 65 | "\n", 66 | " print(\"Name : \", record[ui_pr][\"Name\"])\n", 67 | " print(\"Price (Rs): \", record[ui_pr][\"Price\"])\n", 68 | " print(\"Quantity : \", ui_qn)\n", 69 | " print(\"---------------------------------------------\")\n", 70 | " print(\"Billing : \", ui_qn * record[ui_pr][\"Price\"], \"Rs\")\n", 71 | " print(\"---------------------------------------------\")\n", 72 | "\n", 73 | " record[ui_pr]['Qn'] = record[ui_pr]['Qn'] - ui_qn\n", 74 | "\n", 75 | "else:\n", 76 | " \n", 77 | " print(\"Sorry, We're not having enough quanity of product in our Inventory.\")\n", 78 | " print(\"We're only having \" + str(record[ui_pr]['Qn']) + \" quantity.\")\n", 79 | " print(\"---------------------------------------------\")\n", 80 | " \n", 81 | " ch == str(raw_input(\"Press Y to purchase: \"))\n", 82 | " \n", 83 | " if(ch == \"Y\" or ch == 'y'):\n", 84 | "\n", 85 | " print(\"---------------------------------------------\")\n", 86 | " print(\"Name : \", record[ui_pr][\"Name\"])\n", 87 | " print(\"Price (Rs): \", record[ui_pr][\"Price\"])\n", 88 | " print(\"Quantity : \", record[ui_pr]['Qn'])\n", 89 | " print(\"---------------------------------------------\")\n", 90 | " print(\"Billing : \", record[ui_pr]['Qn'] * record[ui_pr][\"Price\"], \"Rs\")\n", 91 | " print(\"---------------------------------------------\")\n", 92 | "\n", 93 | " record[ui_pr]['Qn'] = 0\n", 94 | " \n", 95 | " else:\n", 96 | " print(\"Thanks!\")\n", 97 | "\n", 98 | "js = json.dumps(record)\n", 99 | "\n", 100 | "fd = open('Record.json','w')\n", 101 | "fd.write(js)\n", 102 | "fd.close()\n", 103 | "\n", 104 | "print('')\n", 105 | "print(\"---------------------------------------------\")\n", 106 | "print(\" Thanks for your order, Inventory Updated! \")\n", 107 | "print(\"---------------------------------------------\")" 108 | ] 109 | }, 110 | { 111 | "cell_type": "code", 112 | "execution_count": 18, 113 | "metadata": { 114 | "scrolled": true 115 | }, 116 | "outputs": [ 117 | { 118 | "data": { 119 | "text/plain": [ 120 | "{u'1001': {u'Name': u'5 Star', u'Price': 10, u'Qn': 195},\n", 121 | " u'1002': {u'Name': u'Bar-One', u'Price': 20, u'Qn': 95},\n", 122 | " u'1003': {u'Name': u'Candy', u'Price': 2, u'Qn': 950},\n", 123 | " u'1004': {u'Name': u'Chocolate Cake', u'Price': 550, u'Qn': 0},\n", 124 | " u'1005': {u'Name': u'Blueberry Cake', u'Price': 650, u'Qn': 0}}" 125 | ] 126 | }, 127 | "execution_count": 18, 128 | "metadata": {}, 129 | "output_type": "execute_result" 130 | } 131 | ], 132 | "source": [ 133 | "record" 134 | ] 135 | }, 136 | { 137 | "cell_type": "code", 138 | "execution_count": 11, 139 | "metadata": {}, 140 | "outputs": [], 141 | "source": [] 142 | }, 143 | { 144 | "cell_type": "code", 145 | "execution_count": null, 146 | "metadata": {}, 147 | "outputs": [], 148 | "source": [] 149 | } 150 | ], 151 | "metadata": { 152 | "kernelspec": { 153 | "display_name": "Python 2", 154 | "language": "python", 155 | "name": "python2" 156 | }, 157 | "language_info": { 158 | "codemirror_mode": { 159 | "name": "ipython", 160 | "version": 2 161 | }, 162 | "file_extension": ".py", 163 | "mimetype": "text/x-python", 164 | "name": "python", 165 | "nbconvert_exporter": "python", 166 | "pygments_lexer": "ipython2", 167 | "version": "2.7.16" 168 | } 169 | }, 170 | "nbformat": 4, 171 | "nbformat_minor": 2 172 | } 173 | -------------------------------------------------------------------------------- /Inventory Management System JSON - Adding Functionalities/Record.json: -------------------------------------------------------------------------------- 1 | {"1001": {"Price": 10, "Name": "5 Star", "Qn": 195}, "1002": {"Price": 20, "Name": "Bar-One", "Qn": 95}, "1003": {"Price": 2, "Name": "Candy", "Qn": 950}, "1004": {"Price": 550, "Name": "Chocolate Cake", "Qn": 8}, "1005": {"Price": 650, "Name": "Blueberry Cake", "Qn": 3}} -------------------------------------------------------------------------------- /Inventory Management System JSON - Conclusion/Inventory Management System - Conclusion.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 55, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "--------------------MENU---------------------\n", 13 | "(u'1005', u'Blueberry Cake', 650, 3)\n", 14 | "(u'1004', u'Chocolate Cake', 550, 6)\n", 15 | "(u'1003', u'Candy', 2, 500)\n", 16 | "(u'1002', u'Bar-One', 20, 90)\n", 17 | "(u'1001', u'5 Star', 10, 188)\n", 18 | "---------------------------------------------\n", 19 | "\n", 20 | "Enter your name : Sandeep\n", 21 | "Enter Mail ID : fhkasdhf\n", 22 | "Enter Phone No : 342523\n", 23 | "Enter product ID : 1002\n", 24 | "Enter Quantity : 100\n", 25 | "---------------------------------------------\n", 26 | "\n", 27 | "Sorry, We're not having enough quanity of product in our Inventory.\n", 28 | "We're only having 90 quantity.\n", 29 | "---------------------------------------------\n", 30 | "Press Y to purchase: Y\n", 31 | "---------------------------------------------\n", 32 | "('Name : ', u'Bar-One')\n", 33 | "('Price (Rs): ', 20)\n", 34 | "('Quantity : ', 90)\n", 35 | "---------------------------------------------\n", 36 | "('Billing : ', 1800, 'Rs')\n", 37 | "---------------------------------------------\n", 38 | "\n", 39 | "---------------------------------------------\n", 40 | " Thanks for your order, Inventory Updated! \n", 41 | "---------------------------------------------\n" 42 | ] 43 | } 44 | ], 45 | "source": [ 46 | "import json\n", 47 | "import time\n", 48 | "\n", 49 | "# Importing Inventory data from Record.json file\n", 50 | "fd = open('Record.json','r')\n", 51 | "js = fd.read()\n", 52 | "fd.close()\n", 53 | "\n", 54 | "# Converting String data to Dictionary\n", 55 | "record = json.loads(js)\n", 56 | "\n", 57 | "# Displaying Menu\n", 58 | "print(\"--------------------MENU---------------------\")\n", 59 | "for key in record.keys():\n", 60 | " print(key, record[key]['Name'], record[key]['Price'], record[key]['Qn'])\n", 61 | "print(\"---------------------------------------------\")\n", 62 | "print('')\n", 63 | "\n", 64 | "# Taking Inputs from the user about their details and purchase\n", 65 | "ui_name = str(raw_input(\"Enter your name : \"))\n", 66 | "ui_mail = str(raw_input(\"Enter Mail ID : \"))\n", 67 | "ui_ph = str(raw_input(\"Enter Phone No : \"))\n", 68 | "ui_pr = str(raw_input(\"Enter product ID : \"))\n", 69 | "ui_qn = int(input(\"Enter Quantity : \"))\n", 70 | "\n", 71 | "print(\"---------------------------------------------\")\n", 72 | "print('')\n", 73 | "\n", 74 | "# If we're having equal or more quantity then the user wants\n", 75 | "if (record[ui_pr]['Qn'] >= ui_qn):\n", 76 | "\n", 77 | " print(\"Name : \", record[ui_pr][\"Name\"])\n", 78 | " print(\"Price (Rs): \", record[ui_pr][\"Price\"])\n", 79 | " print(\"Quantity : \", ui_qn)\n", 80 | " print(\"---------------------------------------------\")\n", 81 | " print(\"Billing : \", ui_qn * record[ui_pr][\"Price\"], \"Rs\")\n", 82 | " print(\"---------------------------------------------\")\n", 83 | "\n", 84 | " # Updating Inventory in Dictionary\n", 85 | " record[ui_pr]['Qn'] = record[ui_pr]['Qn'] - ui_qn\n", 86 | "\n", 87 | " # Generating CSV Transection Detail\n", 88 | " sale = ui_name+\",\"+ui_mail+\",\"+ui_ph+\",\"+ui_pr+\",\"+record[ui_pr][\"Name\"]+\",\"+str(ui_qn)+\",\"+str(record[ui_pr][\"Price\"])+\",\"+str(ui_qn * record[ui_pr][\"Price\"])+\",\"+time.ctime()+\"\\n\"\n", 89 | "\n", 90 | "# If we're less quantity then the user wants\n", 91 | "else:\n", 92 | " \n", 93 | " print(\"Sorry, We're not having enough quanity of product in our Inventory.\")\n", 94 | " print(\"We're only having \" + str(record[ui_pr]['Qn']) + \" quantity.\")\n", 95 | " print(\"---------------------------------------------\")\n", 96 | " \n", 97 | " ch == str(raw_input(\"Press Y to purchase: \"))\n", 98 | " \n", 99 | " # If user wants to purchase the whole quantity for that product\n", 100 | " if(ch == \"Y\" or ch == 'y'):\n", 101 | "\n", 102 | " print(\"---------------------------------------------\")\n", 103 | " print(\"Name : \", record[ui_pr][\"Name\"])\n", 104 | " print(\"Price (Rs): \", record[ui_pr][\"Price\"])\n", 105 | " print(\"Quantity : \", record[ui_pr]['Qn'])\n", 106 | " print(\"---------------------------------------------\")\n", 107 | " print(\"Billing : \", record[ui_pr]['Qn'] * record[ui_pr][\"Price\"], \"Rs\")\n", 108 | " print(\"---------------------------------------------\")\n", 109 | "\n", 110 | " # Updating Inventory in Dictionary\n", 111 | " record[ui_pr]['Qn'] = 0\n", 112 | " \n", 113 | " # Generating CSV Transection Detail\n", 114 | " sale = ui_name+\",\"+ui_mail+\",\"+ui_ph+\",\"+ui_pr+\",\"+record[ui_pr][\"Name\"]+\",\"+str(record[ui_pr]['Qn'])+\",\"+str(record[ui_pr][\"Price\"])+\",\"+str(record[ui_pr]['Qn'] * record[ui_pr][\"Price\"])+\",\"+time.ctime()+\"\\n\"\n", 115 | " \n", 116 | " # If user pressed anything except Y or y\n", 117 | " else:\n", 118 | " print(\"Thanks!\")\n", 119 | " \n", 120 | "# Converting Inventory Dictionary to String\n", 121 | "js = json.dumps(record)\n", 122 | "\n", 123 | "# Updating Inventory and Saving in to my Records.json\n", 124 | "fd = open('Record.json','w')\n", 125 | "fd.write(js)\n", 126 | "fd.close()\n", 127 | "\n", 128 | "# Adding Transection on Sales File\n", 129 | "fd = open('Sales.txt','a')\n", 130 | "fd.write(sale)\n", 131 | "fd.close()\n", 132 | "\n", 133 | "print('')\n", 134 | "print(\"---------------------------------------------\")\n", 135 | "print(\" Thanks for your order, Inventory Updated! \")\n", 136 | "print(\"---------------------------------------------\")" 137 | ] 138 | }, 139 | { 140 | "cell_type": "code", 141 | "execution_count": null, 142 | "metadata": {}, 143 | "outputs": [], 144 | "source": [] 145 | } 146 | ], 147 | "metadata": { 148 | "kernelspec": { 149 | "display_name": "Python 2", 150 | "language": "python", 151 | "name": "python2" 152 | }, 153 | "language_info": { 154 | "codemirror_mode": { 155 | "name": "ipython", 156 | "version": 2 157 | }, 158 | "file_extension": ".py", 159 | "mimetype": "text/x-python", 160 | "name": "python", 161 | "nbconvert_exporter": "python", 162 | "pygments_lexer": "ipython2", 163 | "version": "2.7.16" 164 | } 165 | }, 166 | "nbformat": 4, 167 | "nbformat_minor": 2 168 | } 169 | -------------------------------------------------------------------------------- /Inventory Management System JSON - Conclusion/Record.json: -------------------------------------------------------------------------------- 1 | {"1005": {"Price": 650, "Name": "Blueberry Cake", "Qn": 3}, "1004": {"Price": 550, "Name": "Chocolate Cake", "Qn": 6}, "1003": {"Price": 2, "Name": "Candy", "Qn": 500}, "1002": {"Price": 20, "Name": "Bar-One", "Qn": 0}, "1001": {"Price": 10, "Name": "5 Star", "Qn": 188}} -------------------------------------------------------------------------------- /Inventory Management System JSON - Conclusion/Sales.csv: -------------------------------------------------------------------------------- 1 | Ashish Jangra,ashish@gmail.com,6743648364,1002,Bar-One,5,20,100,Wed Sep 22 16:53:22 2021 2 | Manish,manish@gmail.com,759237492,1003,Candy,30,2,60,Wed Sep 22 16:54:17 2021 3 | Manish,manish@gmail.com,759237492,1003,Candy,30,2,60,Wed Sep 22 16:54:17 2021 4 | Manish,manish@gmail.com,759237492,1003,Candy,30,2,60,Wed Sep 22 16:54:17 2021 5 | Manish,manish@gmail.com,759237492,1003,Candy,30,2,60,Wed Sep 22 16:54:17 2021 6 | Manish,manish@gmail.com,759237492,1003,Candy,30,2,60,Wed Sep 22 16:54:17 2021 7 | Manish,manish@gmail.com,759237492,1003,Candy,30,2,60,Wed Sep 22 16:54:17 2021 8 | Sandeep,sandeep@gmail.com,2395782374,1003,Candy,420,2,840,Wed Sep 22 17:11:48 2021 9 | Sandeep,fhkasdhf,342523,1002,Bar-One,0,20,0,Wed Sep 22 17:12:51 2021 10 | -------------------------------------------------------------------------------- /Inventory Management System JSON - Conclusion/Sales.txt: -------------------------------------------------------------------------------- 1 | Ashish Jangra,ashish@gmail.com,6743648364,1002,Bar-One,5,20,100,Wed Sep 22 16:53:22 2021 2 | Manish,manish@gmail.com,759237492,1003,Candy,30,2,60,Wed Sep 22 16:54:17 2021 3 | Manish,manish@gmail.com,759237492,1003,Candy,30,2,60,Wed Sep 22 16:54:17 2021 4 | Manish,manish@gmail.com,759237492,1003,Candy,30,2,60,Wed Sep 22 16:54:17 2021 5 | Manish,manish@gmail.com,759237492,1003,Candy,30,2,60,Wed Sep 22 16:54:17 2021 6 | Manish,manish@gmail.com,759237492,1003,Candy,30,2,60,Wed Sep 22 16:54:17 2021 7 | Manish,manish@gmail.com,759237492,1003,Candy,30,2,60,Wed Sep 22 16:54:17 2021 8 | Sandeep,sandeep@gmail.com,2395782374,1003,Candy,420,2,840,Wed Sep 22 17:11:48 2021 9 | Sandeep,fhkasdhf,342523,1002,Bar-One,0,20,0,Wed Sep 22 17:12:51 2021 10 | -------------------------------------------------------------------------------- /Inventory Management System JSON - Generating Sales Structure/Inventory Management System - Generating Sales Structure.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 35, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "--------------------MENU---------------------\n", 13 | "(u'1005', u'Blueberry Cake', 650, 3)\n", 14 | "(u'1004', u'Chocolate Cake', 550, 8)\n", 15 | "(u'1003', u'Candy', 2, 950)\n", 16 | "(u'1002', u'Bar-One', 20, 95)\n", 17 | "(u'1001', u'5 Star', 10, 193)\n", 18 | "---------------------------------------------\n", 19 | "\n", 20 | "Enter your name : Ashish\n", 21 | "Enter Mail ID : 34957498\n", 22 | "Enter Phone No : 3423\n", 23 | "Enter product ID : 1004\n", 24 | "Enter Quantity : 2\n", 25 | "---------------------------------------------\n", 26 | "\n", 27 | "('Name : ', u'Chocolate Cake')\n", 28 | "('Price (Rs): ', 550)\n", 29 | "('Quantity : ', 2)\n", 30 | "---------------------------------------------\n", 31 | "('Billing : ', 1100, 'Rs')\n", 32 | "---------------------------------------------\n", 33 | "\n", 34 | "---------------------------------------------\n", 35 | " Thanks for your order, Inventory Updated! \n", 36 | "---------------------------------------------\n" 37 | ] 38 | } 39 | ], 40 | "source": [ 41 | "import json\n", 42 | "\n", 43 | "ch = 'Y'\n", 44 | "fd = open('Record.json','r')\n", 45 | "js = fd.read()\n", 46 | "fd.close()\n", 47 | "\n", 48 | "record = json.loads(js)\n", 49 | "\n", 50 | "print(\"--------------------MENU---------------------\")\n", 51 | "for key in record.keys():\n", 52 | " print(key, record[key]['Name'], record[key]['Price'], record[key]['Qn'])\n", 53 | "print(\"---------------------------------------------\")\n", 54 | "print('')\n", 55 | "\n", 56 | "\n", 57 | "ui_name = str(raw_input(\"Enter your name : \"))\n", 58 | "ui_mail = str(raw_input(\"Enter Mail ID : \"))\n", 59 | "ui_ph = str(raw_input(\"Enter Phone No : \"))\n", 60 | "ui_pr = str(raw_input(\"Enter product ID : \"))\n", 61 | "ui_qn = int(input(\"Enter Quantity : \"))\n", 62 | "\n", 63 | "print(\"---------------------------------------------\")\n", 64 | "print('')\n", 65 | "\n", 66 | "if (record[ui_pr]['Qn'] >= ui_qn):\n", 67 | "\n", 68 | " print(\"Name : \", record[ui_pr][\"Name\"])\n", 69 | " print(\"Price (Rs): \", record[ui_pr][\"Price\"])\n", 70 | " print(\"Quantity : \", ui_qn)\n", 71 | " print(\"---------------------------------------------\")\n", 72 | " print(\"Billing : \", ui_qn * record[ui_pr][\"Price\"], \"Rs\")\n", 73 | " print(\"---------------------------------------------\")\n", 74 | "\n", 75 | " record[ui_pr]['Qn'] = record[ui_pr]['Qn'] - ui_qn\n", 76 | " \n", 77 | " sale = '1'+\",\"+ui_name+\",\"+ui_mail+\",\"+ui_ph+\",\"+ui_pr+\",\"+record[ui_pr][\"Name\"]+\",\"+str(ui_qn)+\",\"+str(record[ui_pr][\"Price\"])+\",\"+str(ui_qn * record[ui_pr][\"Price\"])+\",\"+time.ctime()\n", 78 | "\n", 79 | "else:\n", 80 | " \n", 81 | " print(\"Sorry, We're not having enough quanity of product in our Inventory.\")\n", 82 | " print(\"We're only having \" + str(record[ui_pr]['Qn']) + \" quantity.\")\n", 83 | " print(\"---------------------------------------------\")\n", 84 | " \n", 85 | " ch == str(raw_input(\"Press Y to purchase: \"))\n", 86 | " \n", 87 | " if(ch == \"Y\" or ch == 'y'):\n", 88 | "\n", 89 | " print(\"---------------------------------------------\")\n", 90 | " print(\"Name : \", record[ui_pr][\"Name\"])\n", 91 | " print(\"Price (Rs): \", record[ui_pr][\"Price\"])\n", 92 | " print(\"Quantity : \", record[ui_pr]['Qn'])\n", 93 | " print(\"---------------------------------------------\")\n", 94 | " print(\"Billing : \", record[ui_pr]['Qn'] * record[ui_pr][\"Price\"], \"Rs\")\n", 95 | " print(\"---------------------------------------------\")\n", 96 | "\n", 97 | " record[ui_pr]['Qn'] = 0\n", 98 | " \n", 99 | " sale = '1'+\",\"+ui_name+\",\"+ui_mail+\",\"+ui_ph+\",\"+ui_pr+\",\"+record[ui_pr][\"Name\"]+\",\"+str(record[ui_pr]['Qn'])+\",\"+str(record[ui_pr][\"Price\"])+\",\"+str(record[ui_pr]['Qn'] * record[ui_pr][\"Price\"])+\",\"+time.ctime()\n", 100 | " \n", 101 | " else:\n", 102 | " print(\"Thanks!\")\n", 103 | "\n", 104 | "js = json.dumps(record)\n", 105 | "\n", 106 | "fd = open('Record.json','w')\n", 107 | "fd.write(js)\n", 108 | "fd.close()\n", 109 | "\n", 110 | "print('')\n", 111 | "print(\"---------------------------------------------\")\n", 112 | "print(\" Thanks for your order, Inventory Updated! \")\n", 113 | "print(\"---------------------------------------------\")" 114 | ] 115 | }, 116 | { 117 | "cell_type": "code", 118 | "execution_count": 36, 119 | "metadata": { 120 | "scrolled": true 121 | }, 122 | "outputs": [ 123 | { 124 | "data": { 125 | "text/plain": [ 126 | "u'1,Ashish,34957498,3423,1004,Chocolate Cake,2,550,1100,Wed Sep 22 16:45:04 2021'" 127 | ] 128 | }, 129 | "execution_count": 36, 130 | "metadata": {}, 131 | "output_type": "execute_result" 132 | } 133 | ], 134 | "source": [ 135 | "sale" 136 | ] 137 | }, 138 | { 139 | "cell_type": "code", 140 | "execution_count": 23, 141 | "metadata": {}, 142 | "outputs": [ 143 | { 144 | "data": { 145 | "text/plain": [ 146 | "'Wed Sep 22 16:34:30 2021'" 147 | ] 148 | }, 149 | "execution_count": 23, 150 | "metadata": {}, 151 | "output_type": "execute_result" 152 | } 153 | ], 154 | "source": [ 155 | "time.ctime()" 156 | ] 157 | }, 158 | { 159 | "cell_type": "code", 160 | "execution_count": null, 161 | "metadata": {}, 162 | "outputs": [], 163 | "source": [] 164 | } 165 | ], 166 | "metadata": { 167 | "kernelspec": { 168 | "display_name": "Python 2", 169 | "language": "python", 170 | "name": "python2" 171 | }, 172 | "language_info": { 173 | "codemirror_mode": { 174 | "name": "ipython", 175 | "version": 2 176 | }, 177 | "file_extension": ".py", 178 | "mimetype": "text/x-python", 179 | "name": "python", 180 | "nbconvert_exporter": "python", 181 | "pygments_lexer": "ipython2", 182 | "version": "2.7.16" 183 | } 184 | }, 185 | "nbformat": 4, 186 | "nbformat_minor": 2 187 | } 188 | -------------------------------------------------------------------------------- /Inventory Management System JSON - Generating Sales Structure/Record.json: -------------------------------------------------------------------------------- 1 | {"1005": {"Price": 650, "Name": "Blueberry Cake", "Qn": 3}, "1004": {"Price": 550, "Name": "Chocolate Cake", "Qn": 6}, "1003": {"Price": 2, "Name": "Candy", "Qn": 950}, "1002": {"Price": 20, "Name": "Bar-One", "Qn": 95}, "1001": {"Price": 10, "Name": "5 Star", "Qn": 193}} -------------------------------------------------------------------------------- /Inventory Management System JSON - Generating Sales file/Inventory Management System - Generating Sales file.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 48, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "--------------------MENU---------------------\n", 13 | "(u'1005', u'Blueberry Cake', 650, 3)\n", 14 | "(u'1004', u'Chocolate Cake', 550, 6)\n", 15 | "(u'1003', u'Candy', 2, 950)\n", 16 | "(u'1002', u'Bar-One', 20, 90)\n", 17 | "(u'1001', u'5 Star', 10, 188)\n", 18 | "---------------------------------------------\n", 19 | "\n", 20 | "Enter your name : Manish\n", 21 | "Enter Mail ID : manish@gmail.com\n", 22 | "Enter Phone No : 759237492\n", 23 | "Enter product ID : 1003\n", 24 | "Enter Quantity : 30\n", 25 | "---------------------------------------------\n", 26 | "\n", 27 | "('Name : ', u'Candy')\n", 28 | "('Price (Rs): ', 2)\n", 29 | "('Quantity : ', 30)\n", 30 | "---------------------------------------------\n", 31 | "('Billing : ', 60, 'Rs')\n", 32 | "---------------------------------------------\n", 33 | "\n", 34 | "---------------------------------------------\n", 35 | " Thanks for your order, Inventory Updated! \n", 36 | "---------------------------------------------\n" 37 | ] 38 | } 39 | ], 40 | "source": [ 41 | "import json\n", 42 | "\n", 43 | "ch = 'Y'\n", 44 | "fd = open('Record.json','r')\n", 45 | "js = fd.read()\n", 46 | "fd.close()\n", 47 | "\n", 48 | "record = json.loads(js)\n", 49 | "\n", 50 | "print(\"--------------------MENU---------------------\")\n", 51 | "for key in record.keys():\n", 52 | " print(key, record[key]['Name'], record[key]['Price'], record[key]['Qn'])\n", 53 | "print(\"---------------------------------------------\")\n", 54 | "print('')\n", 55 | "\n", 56 | "\n", 57 | "ui_name = str(raw_input(\"Enter your name : \"))\n", 58 | "ui_mail = str(raw_input(\"Enter Mail ID : \"))\n", 59 | "ui_ph = str(raw_input(\"Enter Phone No : \"))\n", 60 | "ui_pr = str(raw_input(\"Enter product ID : \"))\n", 61 | "ui_qn = int(input(\"Enter Quantity : \"))\n", 62 | "\n", 63 | "print(\"---------------------------------------------\")\n", 64 | "print('')\n", 65 | "\n", 66 | "if (record[ui_pr]['Qn'] >= ui_qn):\n", 67 | "\n", 68 | " print(\"Name : \", record[ui_pr][\"Name\"])\n", 69 | " print(\"Price (Rs): \", record[ui_pr][\"Price\"])\n", 70 | " print(\"Quantity : \", ui_qn)\n", 71 | " print(\"---------------------------------------------\")\n", 72 | " print(\"Billing : \", ui_qn * record[ui_pr][\"Price\"], \"Rs\")\n", 73 | " print(\"---------------------------------------------\")\n", 74 | "\n", 75 | " record[ui_pr]['Qn'] = record[ui_pr]['Qn'] - ui_qn\n", 76 | " \n", 77 | " sale = ui_name+\",\"+ui_mail+\",\"+ui_ph+\",\"+ui_pr+\",\"+record[ui_pr][\"Name\"]+\",\"+str(ui_qn)+\",\"+str(record[ui_pr][\"Price\"])+\",\"+str(ui_qn * record[ui_pr][\"Price\"])+\",\"+time.ctime()+\"\\n\"\n", 78 | "\n", 79 | "else:\n", 80 | " \n", 81 | " print(\"Sorry, We're not having enough quanity of product in our Inventory.\")\n", 82 | " print(\"We're only having \" + str(record[ui_pr]['Qn']) + \" quantity.\")\n", 83 | " print(\"---------------------------------------------\")\n", 84 | " \n", 85 | " ch == str(raw_input(\"Press Y to purchase: \"))\n", 86 | " \n", 87 | " if(ch == \"Y\" or ch == 'y'):\n", 88 | "\n", 89 | " print(\"---------------------------------------------\")\n", 90 | " print(\"Name : \", record[ui_pr][\"Name\"])\n", 91 | " print(\"Price (Rs): \", record[ui_pr][\"Price\"])\n", 92 | " print(\"Quantity : \", record[ui_pr]['Qn'])\n", 93 | " print(\"---------------------------------------------\")\n", 94 | " print(\"Billing : \", record[ui_pr]['Qn'] * record[ui_pr][\"Price\"], \"Rs\")\n", 95 | " print(\"---------------------------------------------\")\n", 96 | "\n", 97 | " record[ui_pr]['Qn'] = 0\n", 98 | " \n", 99 | " sale = ui_name+\",\"+ui_mail+\",\"+ui_ph+\",\"+ui_pr+\",\"+record[ui_pr][\"Name\"]+\",\"+str(record[ui_pr]['Qn'])+\",\"+str(record[ui_pr][\"Price\"])+\",\"+str(record[ui_pr]['Qn'] * record[ui_pr][\"Price\"])+\",\"+time.ctime()+\"\\n\"\n", 100 | " \n", 101 | " else:\n", 102 | " print(\"Thanks!\")\n", 103 | " \n", 104 | "js = json.dumps(record)\n", 105 | "\n", 106 | "fd = open('Record.json','w')\n", 107 | "fd.write(js)\n", 108 | "fd.close()\n", 109 | "\n", 110 | "fd = open('Sales.txt','a')\n", 111 | "fd.write(sale)\n", 112 | "fd.close()\n", 113 | "\n", 114 | "print('')\n", 115 | "print(\"---------------------------------------------\")\n", 116 | "print(\" Thanks for your order, Inventory Updated! \")\n", 117 | "print(\"---------------------------------------------\")" 118 | ] 119 | } 120 | ], 121 | "metadata": { 122 | "kernelspec": { 123 | "display_name": "Python 2", 124 | "language": "python", 125 | "name": "python2" 126 | }, 127 | "language_info": { 128 | "codemirror_mode": { 129 | "name": "ipython", 130 | "version": 2 131 | }, 132 | "file_extension": ".py", 133 | "mimetype": "text/x-python", 134 | "name": "python", 135 | "nbconvert_exporter": "python", 136 | "pygments_lexer": "ipython2", 137 | "version": "2.7.16" 138 | } 139 | }, 140 | "nbformat": 4, 141 | "nbformat_minor": 2 142 | } 143 | -------------------------------------------------------------------------------- /Inventory Management System JSON - Generating Sales file/Record.json: -------------------------------------------------------------------------------- 1 | {"1005": {"Price": 650, "Name": "Blueberry Cake", "Qn": 3}, "1004": {"Price": 550, "Name": "Chocolate Cake", "Qn": 6}, "1003": {"Price": 2, "Name": "Candy", "Qn": 920}, "1002": {"Price": 20, "Name": "Bar-One", "Qn": 90}, "1001": {"Price": 10, "Name": "5 Star", "Qn": 188}} -------------------------------------------------------------------------------- /Inventory Management System JSON - Generating Sales file/Sales.csv: -------------------------------------------------------------------------------- 1 | Ashish Jangra,ashish@gmail.com,6743648364,1002,Bar-One,5,20,100,Wed Sep 22 16:53:22 2021 2 | Manish,manish@gmail.com,759237492,1003,Candy,30,2,60,Wed Sep 22 16:54:17 2021 3 | Manish,manish@gmail.com,759237492,1003,Candy,30,2,60,Wed Sep 22 16:54:17 2021 4 | Manish,manish@gmail.com,759237492,1003,Candy,30,2,60,Wed Sep 22 16:54:17 2021 5 | Manish,manish@gmail.com,759237492,1003,Candy,30,2,60,Wed Sep 22 16:54:17 2021 6 | Manish,manish@gmail.com,759237492,1003,Candy,30,2,60,Wed Sep 22 16:54:17 2021 7 | Manish,manish@gmail.com,759237492,1003,Candy,30,2,60,Wed Sep 22 16:54:17 2021 8 | -------------------------------------------------------------------------------- /Inventory Management System JSON - Generating Sales file/Sales.txt: -------------------------------------------------------------------------------- 1 | Ashish Jangra,ashish@gmail.com,6743648364,1002,Bar-One,5,20,100,Wed Sep 22 16:53:22 2021 2 | Manish,manish@gmail.com,759237492,1003,Candy,30,2,60,Wed Sep 22 16:54:17 2021 3 | Manish,manish@gmail.com,759237492,1003,Candy,30,2,60,Wed Sep 22 16:54:17 2021 4 | Manish,manish@gmail.com,759237492,1003,Candy,30,2,60,Wed Sep 22 16:54:17 2021 5 | Manish,manish@gmail.com,759237492,1003,Candy,30,2,60,Wed Sep 22 16:54:17 2021 6 | Manish,manish@gmail.com,759237492,1003,Candy,30,2,60,Wed Sep 22 16:54:17 2021 7 | Manish,manish@gmail.com,759237492,1003,Candy,30,2,60,Wed Sep 22 16:54:17 2021 8 | -------------------------------------------------------------------------------- /Inventory Management System JSON - Saving Record/Inventory Management System - Saving Record on JSON.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import json\n", 10 | "\n", 11 | "record = {1001: {'Name': \"5 Star\" , \"Price\" : 10 , \"Qn\" : 200},\n", 12 | " 1002: {'Name': \"Bar-One\" , \"Price\" : 20 , \"Qn\" : 100 },\n", 13 | " 1003: {'Name': \"Candy\" , \"Price\" : 2 , \"Qn\" : 1000},\n", 14 | " 1004: {'Name': \"Chocolate Cake\" , \"Price\" : 550, \"Qn\" : 8 },\n", 15 | " 1005: {'Name': \"Blueberry Cake\" , \"Price\" : 650, \"Qn\" : 5 }}" 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": 17, 21 | "metadata": {}, 22 | "outputs": [ 23 | { 24 | "name": "stdout", 25 | "output_type": "stream", 26 | "text": [ 27 | "--------------------MENU---------------------\n", 28 | "(1001, '5 Star', 10, '5 Star')\n", 29 | "(1002, 'Bar-One', 20, 'Bar-One')\n", 30 | "(1003, 'Candy', 2, 'Candy')\n", 31 | "(1004, 'Chocolate Cake', 550, 'Chocolate Cake')\n", 32 | "(1005, 'Blueberry Cake', 650, 'Blueberry Cake')\n", 33 | "---------------------------------------------\n", 34 | "\n", 35 | "Enter product ID : 1005\n", 36 | "Enter Quantiry : 2\n", 37 | "---------------------------------------------\n", 38 | "\n", 39 | "('Name : ', 'Blueberry Cake')\n", 40 | "('Price (Rs): ', 650)\n", 41 | "('Quantity : ', 2)\n", 42 | "---------------------------------------------\n", 43 | "('Billing : ', 1300, 'Rs')\n", 44 | "---------------------------------------------\n", 45 | "\n", 46 | "---------------------------------------------\n", 47 | " Thanks for your order, Inventory Updated! \n", 48 | "---------------------------------------------\n" 49 | ] 50 | } 51 | ], 52 | "source": [ 53 | "print(\"--------------------MENU---------------------\")\n", 54 | "for key in record.keys():\n", 55 | " print(key, record[key]['Name'], record[key]['Price'], record[key]['Name'])\n", 56 | "print(\"---------------------------------------------\")\n", 57 | "print('')\n", 58 | "\n", 59 | "ui_pr = int(input(\"Enter product ID : \"))\n", 60 | "ui_qn = int(input(\"Enter Quantiry : \"))\n", 61 | "\n", 62 | "print(\"---------------------------------------------\")\n", 63 | "print('')\n", 64 | "\n", 65 | "print(\"Name : \", record[ui_pr][\"Name\"])\n", 66 | "print(\"Price (Rs): \", record[ui_pr][\"Price\"])\n", 67 | "print(\"Quantity : \", ui_qn)\n", 68 | "print(\"---------------------------------------------\")\n", 69 | "print(\"Billing : \", ui_qn * record[ui_pr][\"Price\"], \"Rs\")\n", 70 | "print(\"---------------------------------------------\")\n", 71 | "\n", 72 | "record[ui_pr]['Qn'] = record[ui_pr]['Qn'] - ui_qn\n", 73 | "\n", 74 | "js = json.dumps(record)\n", 75 | "\n", 76 | "fd = open('Record.json','w')\n", 77 | "fd.write(js)\n", 78 | "fd.close()\n", 79 | "\n", 80 | "print('')\n", 81 | "print(\"---------------------------------------------\")\n", 82 | "print(\" Thanks for your order, Inventory Updated! \")\n", 83 | "print(\"---------------------------------------------\")" 84 | ] 85 | }, 86 | { 87 | "cell_type": "code", 88 | "execution_count": 2, 89 | "metadata": { 90 | "scrolled": true 91 | }, 92 | "outputs": [ 93 | { 94 | "data": { 95 | "text/plain": [ 96 | "{1001: {'Name': '5 Star', 'Price': 10, 'Qn': 200},\n", 97 | " 1002: {'Name': 'Bar-One', 'Price': 20, 'Qn': 100},\n", 98 | " 1003: {'Name': 'Candy', 'Price': 2, 'Qn': 1000},\n", 99 | " 1004: {'Name': 'Chocolate Cake', 'Price': 550, 'Qn': 8},\n", 100 | " 1005: {'Name': 'Blueberry Cake', 'Price': 650, 'Qn': 5}}" 101 | ] 102 | }, 103 | "execution_count": 2, 104 | "metadata": {}, 105 | "output_type": "execute_result" 106 | } 107 | ], 108 | "source": [ 109 | "record" 110 | ] 111 | }, 112 | { 113 | "cell_type": "code", 114 | "execution_count": 10, 115 | "metadata": {}, 116 | "outputs": [ 117 | { 118 | "data": { 119 | "text/plain": [ 120 | "dict" 121 | ] 122 | }, 123 | "execution_count": 10, 124 | "metadata": {}, 125 | "output_type": "execute_result" 126 | } 127 | ], 128 | "source": [ 129 | "type(record)" 130 | ] 131 | }, 132 | { 133 | "cell_type": "code", 134 | "execution_count": 7, 135 | "metadata": {}, 136 | "outputs": [], 137 | "source": [] 138 | }, 139 | { 140 | "cell_type": "code", 141 | "execution_count": 8, 142 | "metadata": {}, 143 | "outputs": [ 144 | { 145 | "data": { 146 | "text/plain": [ 147 | "'{\"1001\": {\"Price\": 10, \"Name\": \"5 Star\", \"Qn\": 200}, \"1002\": {\"Price\": 20, \"Name\": \"Bar-One\", \"Qn\": 100}, \"1003\": {\"Price\": 2, \"Name\": \"Candy\", \"Qn\": 1000}, \"1004\": {\"Price\": 550, \"Name\": \"Chocolate Cake\", \"Qn\": 8}, \"1005\": {\"Price\": 650, \"Name\": \"Blueberry Cake\", \"Qn\": 5}}'" 148 | ] 149 | }, 150 | "execution_count": 8, 151 | "metadata": {}, 152 | "output_type": "execute_result" 153 | } 154 | ], 155 | "source": [ 156 | "js" 157 | ] 158 | }, 159 | { 160 | "cell_type": "code", 161 | "execution_count": 9, 162 | "metadata": {}, 163 | "outputs": [ 164 | { 165 | "data": { 166 | "text/plain": [ 167 | "str" 168 | ] 169 | }, 170 | "execution_count": 9, 171 | "metadata": {}, 172 | "output_type": "execute_result" 173 | } 174 | ], 175 | "source": [ 176 | "type(js)" 177 | ] 178 | }, 179 | { 180 | "cell_type": "code", 181 | "execution_count": 11, 182 | "metadata": {}, 183 | "outputs": [], 184 | "source": [] 185 | }, 186 | { 187 | "cell_type": "code", 188 | "execution_count": null, 189 | "metadata": {}, 190 | "outputs": [], 191 | "source": [] 192 | } 193 | ], 194 | "metadata": { 195 | "kernelspec": { 196 | "display_name": "Python 2", 197 | "language": "python", 198 | "name": "python2" 199 | }, 200 | "language_info": { 201 | "codemirror_mode": { 202 | "name": "ipython", 203 | "version": 2 204 | }, 205 | "file_extension": ".py", 206 | "mimetype": "text/x-python", 207 | "name": "python", 208 | "nbconvert_exporter": "python", 209 | "pygments_lexer": "ipython2", 210 | "version": "2.7.16" 211 | } 212 | }, 213 | "nbformat": 4, 214 | "nbformat_minor": 2 215 | } 216 | -------------------------------------------------------------------------------- /Inventory Management System JSON - Saving Record/Record.json: -------------------------------------------------------------------------------- 1 | {"1001": {"Price": 10, "Name": "5 Star", "Qn": 195}, "1002": {"Price": 20, "Name": "Bar-One", "Qn": 95}, "1003": {"Price": 2, "Name": "Candy", "Qn": 950}, "1004": {"Price": 550, "Name": "Chocolate Cake", "Qn": 8}, "1005": {"Price": 650, "Name": "Blueberry Cake", "Qn": 3}} -------------------------------------------------------------------------------- /Inventory Management System JSON - Updating Inventory/Inventory Management System - Updating Inventory.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 2, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "record = {1001: {'Name': \"5 Star\" , \"Price\" : 10 , \"Qn\" : 200},\n", 10 | " 1002: {'Name': \"Bar-One\" , \"Price\" : 20 , \"Qn\" : 100 },\n", 11 | " 1003: {'Name': \"Candy\" , \"Price\" : 2 , \"Qn\" : 1000},\n", 12 | " 1004: {'Name': \"Chocolate Cake\" , \"Price\" : 550, \"Qn\" : 8 },\n", 13 | " 1005: {'Name': \"Blueberry Cake\" , \"Price\" : 650, \"Qn\" : 5 }}" 14 | ] 15 | }, 16 | { 17 | "cell_type": "code", 18 | "execution_count": 3, 19 | "metadata": {}, 20 | "outputs": [ 21 | { 22 | "name": "stdout", 23 | "output_type": "stream", 24 | "text": [ 25 | "--------------------MENU---------------------\n", 26 | "(1001, '5 Star', 10, '5 Star')\n", 27 | "(1002, 'Bar-One', 20, 'Bar-One')\n", 28 | "(1003, 'Candy', 2, 'Candy')\n", 29 | "(1004, 'Chocolate Cake', 550, 'Chocolate Cake')\n", 30 | "(1005, 'Blueberry Cake', 650, 'Blueberry Cake')\n", 31 | "---------------------------------------------\n", 32 | "\n", 33 | "Enter product ID : 1001\n", 34 | "Enter Quantiry : 2\n", 35 | "---------------------------------------------\n", 36 | "\n", 37 | "('Name : ', '5 Star')\n", 38 | "('Price (Rs): ', 10)\n", 39 | "('Quantity : ', 2)\n", 40 | "---------------------------------------------\n", 41 | "('Billing : ', 20, 'Rs')\n", 42 | "---------------------------------------------\n", 43 | "\n", 44 | "---------------------------------------------\n", 45 | " Thanks for your order, Inventory Updated! \n", 46 | "---------------------------------------------\n" 47 | ] 48 | } 49 | ], 50 | "source": [ 51 | "print(\"--------------------MENU---------------------\")\n", 52 | "for key in record.keys():\n", 53 | " print(key, record[key]['Name'], record[key]['Price'], record[key]['Name'])\n", 54 | "print(\"---------------------------------------------\")\n", 55 | "print('')\n", 56 | "\n", 57 | "ui_pr = int(input(\"Enter product ID : \"))\n", 58 | "ui_qn = int(input(\"Enter Quantiry : \"))\n", 59 | "\n", 60 | "print(\"---------------------------------------------\")\n", 61 | "print('')\n", 62 | "\n", 63 | "print(\"Name : \", record[ui_pr][\"Name\"])\n", 64 | "print(\"Price (Rs): \", record[ui_pr][\"Price\"])\n", 65 | "print(\"Quantity : \", ui_qn)\n", 66 | "print(\"---------------------------------------------\")\n", 67 | "print(\"Billing : \", ui_qn * record[ui_pr][\"Price\"], \"Rs\")\n", 68 | "print(\"---------------------------------------------\")\n", 69 | "\n", 70 | "record[ui_pr]['Qn'] = record[ui_pr]['Qn'] - ui_qn\n", 71 | "\n", 72 | "print('')\n", 73 | "print(\"---------------------------------------------\")\n", 74 | "print(\" Thanks for your order, Inventory Updated! \")\n", 75 | "print(\"---------------------------------------------\")" 76 | ] 77 | }, 78 | { 79 | "cell_type": "code", 80 | "execution_count": 44, 81 | "metadata": {}, 82 | "outputs": [ 83 | { 84 | "data": { 85 | "text/plain": [ 86 | "95" 87 | ] 88 | }, 89 | "execution_count": 44, 90 | "metadata": {}, 91 | "output_type": "execute_result" 92 | } 93 | ], 94 | "source": [ 95 | "record[ui_pr]['Qn']" 96 | ] 97 | }, 98 | { 99 | "cell_type": "code", 100 | "execution_count": 38, 101 | "metadata": {}, 102 | "outputs": [ 103 | { 104 | "data": { 105 | "text/plain": [ 106 | "1" 107 | ] 108 | }, 109 | "execution_count": 38, 110 | "metadata": {}, 111 | "output_type": "execute_result" 112 | } 113 | ], 114 | "source": [ 115 | "ui_qn" 116 | ] 117 | }, 118 | { 119 | "cell_type": "code", 120 | "execution_count": 40, 121 | "metadata": {}, 122 | "outputs": [ 123 | { 124 | "data": { 125 | "text/plain": [ 126 | "7" 127 | ] 128 | }, 129 | "execution_count": 40, 130 | "metadata": {}, 131 | "output_type": "execute_result" 132 | } 133 | ], 134 | "source": [ 135 | "record[ui_pr]['Qn'] - ui_qn" 136 | ] 137 | }, 138 | { 139 | "cell_type": "code", 140 | "execution_count": 41, 141 | "metadata": {}, 142 | "outputs": [], 143 | "source": [] 144 | }, 145 | { 146 | "cell_type": "code", 147 | "execution_count": 4, 148 | "metadata": {}, 149 | "outputs": [ 150 | { 151 | "data": { 152 | "text/plain": [ 153 | "{1001: {'Name': '5 Star', 'Price': 10, 'Qn': 198},\n", 154 | " 1002: {'Name': 'Bar-One', 'Price': 20, 'Qn': 100},\n", 155 | " 1003: {'Name': 'Candy', 'Price': 2, 'Qn': 1000},\n", 156 | " 1004: {'Name': 'Chocolate Cake', 'Price': 550, 'Qn': 8},\n", 157 | " 1005: {'Name': 'Blueberry Cake', 'Price': 650, 'Qn': 5}}" 158 | ] 159 | }, 160 | "execution_count": 4, 161 | "metadata": {}, 162 | "output_type": "execute_result" 163 | } 164 | ], 165 | "source": [ 166 | "record" 167 | ] 168 | }, 169 | { 170 | "cell_type": "code", 171 | "execution_count": null, 172 | "metadata": {}, 173 | "outputs": [], 174 | "source": [] 175 | } 176 | ], 177 | "metadata": { 178 | "kernelspec": { 179 | "display_name": "Python 2", 180 | "language": "python", 181 | "name": "python2" 182 | }, 183 | "language_info": { 184 | "codemirror_mode": { 185 | "name": "ipython", 186 | "version": 2 187 | }, 188 | "file_extension": ".py", 189 | "mimetype": "text/x-python", 190 | "name": "python", 191 | "nbconvert_exporter": "python", 192 | "pygments_lexer": "ipython2", 193 | "version": "2.7.16" 194 | } 195 | }, 196 | "nbformat": 4, 197 | "nbformat_minor": 2 198 | } 199 | -------------------------------------------------------------------------------- /Inventory Management System JSON- Loading Record/Inventory Management System - Loading Record from JSON.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [ 8 | { 9 | "name": "stdout", 10 | "output_type": "stream", 11 | "text": [ 12 | "--------------------MENU---------------------\n", 13 | "(u'1005', u'Blueberry Cake', 650, 1)\n", 14 | "(u'1004', u'Chocolate Cake', 550, 8)\n", 15 | "(u'1003', u'Candy', 2, 500)\n", 16 | "(u'1002', u'Bar-One', 20, 50)\n", 17 | "(u'1001', u'5 Star', 10, 145)\n", 18 | "---------------------------------------------\n", 19 | "\n", 20 | "Enter product ID : 1005\n", 21 | "Enter Quantiry : 5\n", 22 | "---------------------------------------------\n", 23 | "\n", 24 | "('Name : ', u'Blueberry Cake')\n", 25 | "('Price (Rs): ', 650)\n", 26 | "('Quantity : ', 5)\n", 27 | "---------------------------------------------\n", 28 | "('Billing : ', 3250, 'Rs')\n", 29 | "---------------------------------------------\n", 30 | "\n", 31 | "---------------------------------------------\n", 32 | " Thanks for your order, Inventory Updated! \n", 33 | "---------------------------------------------\n" 34 | ] 35 | } 36 | ], 37 | "source": [ 38 | "import json\n", 39 | "\n", 40 | "fd = open('Record.json','r')\n", 41 | "js = fd.read()\n", 42 | "fd.close()\n", 43 | "\n", 44 | "record = json.loads(js)\n", 45 | "\n", 46 | "print(\"--------------------MENU---------------------\")\n", 47 | "for key in record.keys():\n", 48 | " print(key, record[key]['Name'], record[key]['Price'], record[key]['Qn'])\n", 49 | "print(\"---------------------------------------------\")\n", 50 | "print('')\n", 51 | "\n", 52 | "ui_pr = str(input(\"Enter product ID : \"))\n", 53 | "ui_qn = int(input(\"Enter Quantiry : \"))\n", 54 | "\n", 55 | "print(\"---------------------------------------------\")\n", 56 | "print('')\n", 57 | "\n", 58 | "print(\"Name : \", record[ui_pr][\"Name\"])\n", 59 | "print(\"Price (Rs): \", record[ui_pr][\"Price\"])\n", 60 | "print(\"Quantity : \", ui_qn)\n", 61 | "print(\"---------------------------------------------\")\n", 62 | "print(\"Billing : \", ui_qn * record[ui_pr][\"Price\"], \"Rs\")\n", 63 | "print(\"---------------------------------------------\")\n", 64 | "\n", 65 | "record[ui_pr]['Qn'] = record[ui_pr]['Qn'] - ui_qn\n", 66 | "\n", 67 | "js = json.dumps(record)\n", 68 | "\n", 69 | "fd = open('Record.json','w')\n", 70 | "fd.write(js)\n", 71 | "fd.close()\n", 72 | "\n", 73 | "print('')\n", 74 | "print(\"---------------------------------------------\")\n", 75 | "print(\" Thanks for your order, Inventory Updated! \")\n", 76 | "print(\"---------------------------------------------\")" 77 | ] 78 | }, 79 | { 80 | "cell_type": "code", 81 | "execution_count": 2, 82 | "metadata": { 83 | "scrolled": true 84 | }, 85 | "outputs": [ 86 | { 87 | "data": { 88 | "text/plain": [ 89 | "{u'1001': {u'Name': u'5 Star', u'Price': 10, u'Qn': 145},\n", 90 | " u'1002': {u'Name': u'Bar-One', u'Price': 20, u'Qn': 50},\n", 91 | " u'1003': {u'Name': u'Candy', u'Price': 2, u'Qn': 500},\n", 92 | " u'1004': {u'Name': u'Chocolate Cake', u'Price': 550, u'Qn': 8},\n", 93 | " u'1005': {u'Name': u'Blueberry Cake', u'Price': 650, u'Qn': -4}}" 94 | ] 95 | }, 96 | "execution_count": 2, 97 | "metadata": {}, 98 | "output_type": "execute_result" 99 | } 100 | ], 101 | "source": [ 102 | "record" 103 | ] 104 | }, 105 | { 106 | "cell_type": "code", 107 | "execution_count": 11, 108 | "metadata": {}, 109 | "outputs": [], 110 | "source": [] 111 | }, 112 | { 113 | "cell_type": "code", 114 | "execution_count": null, 115 | "metadata": {}, 116 | "outputs": [], 117 | "source": [] 118 | } 119 | ], 120 | "metadata": { 121 | "kernelspec": { 122 | "display_name": "Python 2", 123 | "language": "python", 124 | "name": "python2" 125 | }, 126 | "language_info": { 127 | "codemirror_mode": { 128 | "name": "ipython", 129 | "version": 2 130 | }, 131 | "file_extension": ".py", 132 | "mimetype": "text/x-python", 133 | "name": "python", 134 | "nbconvert_exporter": "python", 135 | "pygments_lexer": "ipython2", 136 | "version": "2.7.16" 137 | } 138 | }, 139 | "nbformat": 4, 140 | "nbformat_minor": 2 141 | } 142 | -------------------------------------------------------------------------------- /Inventory Management System JSON- Loading Record/Record.json: -------------------------------------------------------------------------------- 1 | {"1005": {"Price": 650, "Name": "Blueberry Cake", "Qn": -4}, "1004": {"Price": 550, "Name": "Chocolate Cake", "Qn": 8}, "1003": {"Price": 2, "Name": "Candy", "Qn": 500}, "1002": {"Price": 20, "Name": "Bar-One", "Qn": 50}, "1001": {"Price": 10, "Name": "5 Star", "Qn": 145}} -------------------------------------------------------------------------------- /Inventory Management with Files - Add Functionalities/Inventory Management with Files - Add Functionalities.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "7090ccd4", 6 | "metadata": {}, 7 | "source": [ 8 | "## Product Details\n", 9 | "1. Product ID\n", 10 | "2. Name of Product\n", 11 | "3. Price of Product\n", 12 | "4. Quantity" 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": 14, 18 | "id": "e189d341", 19 | "metadata": { 20 | "scrolled": true 21 | }, 22 | "outputs": [ 23 | { 24 | "name": "stdout", 25 | "output_type": "stream", 26 | "text": [ 27 | "Enter product ID: 3\n", 28 | "Enter product Quantity: 8\n", 29 | "Sorry, We're not having enought quantity.\n", 30 | "We're having only 5 quantity.\n", 31 | "Would you like to purchase it?\n", 32 | "Press Y/NY\n", 33 | "-----------------------------\n", 34 | "Product Name : Cake\n", 35 | "Price : 300\n", 36 | "Quantity : 5\n", 37 | "-----------------------------\n", 38 | "Billing Amount : 1500\n", 39 | "-----------------------------\n", 40 | "-------------------\n", 41 | "Inventory Updated\n" 42 | ] 43 | } 44 | ], 45 | "source": [ 46 | "# Reading the Inventory\n", 47 | "fd = open('Inventory.txt','r') \n", 48 | "products = fd.read().split('\\n')\n", 49 | "fd.close()\n", 50 | "\n", 51 | "# Taling User Input\n", 52 | "ui_prod_id = input(\"Enter product ID: \")\n", 53 | "ui_prod_qn = input(\"Enter product Quantity: \")\n", 54 | "\n", 55 | "updated_product_lst = []\n", 56 | "\n", 57 | "# Going through each product detail\n", 58 | "for product in products:\n", 59 | " \n", 60 | " prod_details = product.split(',')\n", 61 | " \n", 62 | " if(prod_details[0] == ui_prod_id):\n", 63 | " # Checking if product exists or not\n", 64 | "\n", 65 | " if (int(ui_prod_qn) <= int(prod_details[3])):\n", 66 | " # If we're having enough quantity\n", 67 | " \n", 68 | " print(\"-----------------------------\")\n", 69 | " print(\"Product Name : \", prod_details[1])\n", 70 | " print(\"Price : \", prod_details[2]) \n", 71 | " print(\"Quantity : \", ui_prod_qn) \n", 72 | " print(\"-----------------------------\")\n", 73 | " print(\"Billing Amount : \", int(ui_prod_qn) * int(prod_details[2]))\n", 74 | " print(\"-----------------------------\")\n", 75 | "\n", 76 | " prod_details[3] = str(int(prod_details[3]) - int(ui_prod_qn))\n", 77 | " \n", 78 | " else:\n", 79 | " # If we're not having enough quantity\n", 80 | " \n", 81 | " print(\"Sorry, We're not having enought quantity.\")\n", 82 | " print(\"We're having only\",prod_details[3],'quantity.')\n", 83 | " print(\"Would you like to purchase it?\")\n", 84 | " \n", 85 | " ch = input(\"Press Y/N: \")\n", 86 | " \n", 87 | " if (ch == 'Y' or ch == 'y'):\n", 88 | " # If you want to purchase with remaining quantity\n", 89 | " \n", 90 | " print(\"-----------------------------\")\n", 91 | " print(\"Product Name : \", prod_details[1])\n", 92 | " print(\"Price : \", prod_details[2]) \n", 93 | " print(\"Quantity : \", prod_details[3]) \n", 94 | " print(\"-----------------------------\")\n", 95 | " print(\"Billing Amount : \", int(prod_details[3]) * int(prod_details[2]))\n", 96 | " print(\"-----------------------------\")\n", 97 | "\n", 98 | " prod_details[3] = '0'\n", 99 | "\n", 100 | " else:\n", 101 | " print(\"Thanks\")\n", 102 | " \n", 103 | " # Updating my Inventory List\n", 104 | " updated_product_lst.append(prod_details)\n", 105 | " \n", 106 | "\n", 107 | " \n", 108 | "lst = []\n", 109 | "\n", 110 | "# Updating my Inventory String\n", 111 | "for i in updated_product_lst:\n", 112 | " prod = i[0] +\",\"+ i[1] +\",\"+ i[2] +\",\"+ i[3] + '\\n'\n", 113 | " lst.append(prod)\n", 114 | "\n", 115 | " \n", 116 | "lst[-1] = lst[-1][:-1]\n", 117 | " \n", 118 | "\n", 119 | "# Updating Inventory File\n", 120 | "fd = open('Inventory.txt','w')\n", 121 | "\n", 122 | "for i in lst:\n", 123 | " fd.write(i)\n", 124 | "\n", 125 | "fd.close()\n", 126 | "\n", 127 | "print(\"-------------------\")\n", 128 | "print(\"Inventory Updated\")" 129 | ] 130 | }, 131 | { 132 | "cell_type": "code", 133 | "execution_count": null, 134 | "id": "fd5b609a", 135 | "metadata": {}, 136 | "outputs": [], 137 | "source": [] 138 | } 139 | ], 140 | "metadata": { 141 | "kernelspec": { 142 | "display_name": "Python 3", 143 | "language": "python", 144 | "name": "python3" 145 | }, 146 | "language_info": { 147 | "codemirror_mode": { 148 | "name": "ipython", 149 | "version": 3 150 | }, 151 | "file_extension": ".py", 152 | "mimetype": "text/x-python", 153 | "name": "python", 154 | "nbconvert_exporter": "python", 155 | "pygments_lexer": "ipython3", 156 | "version": "3.8.8" 157 | } 158 | }, 159 | "nbformat": 4, 160 | "nbformat_minor": 5 161 | } 162 | -------------------------------------------------------------------------------- /Inventory Management with Files - Add Functionalities/Inventory.txt: -------------------------------------------------------------------------------- 1 | 1,5 Star,5,100 2 | 2,Milky Bar,5,200 3 | 3,Cake,300,10 4 | 4,Candy,1,1000 -------------------------------------------------------------------------------- /Inventory Management with Files - Generate Sales/Inventory Management with Files - Generate Sales.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "7090ccd4", 6 | "metadata": {}, 7 | "source": [ 8 | "## Product Details\n", 9 | "1. Product ID\n", 10 | "2. Name of Product\n", 11 | "3. Price of Product\n", 12 | "4. Quantity" 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": 21, 18 | "id": "e189d341", 19 | "metadata": { 20 | "scrolled": true 21 | }, 22 | "outputs": [ 23 | { 24 | "name": "stdout", 25 | "output_type": "stream", 26 | "text": [ 27 | "Enter your Name: Ahsihs\n", 28 | "Enter your Phone No: 4\n", 29 | "Enter your Mail: 324\n", 30 | "Enter product ID: 3\n", 31 | "Enter product Quantity: 2\n", 32 | "-----------------------------\n", 33 | "Product Name : Cake\n", 34 | "Price : 300\n", 35 | "Quantity : 2\n", 36 | "-----------------------------\n", 37 | "Billing Amount : 600\n", 38 | "-----------------------------\n", 39 | "-------------------\n", 40 | "Inventory Updated\n" 41 | ] 42 | } 43 | ], 44 | "source": [ 45 | "import time\n", 46 | "\n", 47 | "# Reading the Inventory\n", 48 | "fd = open('Inventory.txt','r') \n", 49 | "products = fd.read().split('\\n')\n", 50 | "fd.close()\n", 51 | "\n", 52 | "# Taking User Input\n", 53 | "ui_username = input(\"Enter your Name: \")\n", 54 | "ui_phone = input(\"Enter your Phone No: \")\n", 55 | "ui_mail = input(\"Enter your Mail: \")\n", 56 | "ui_prod_id = input(\"Enter product ID: \")\n", 57 | "ui_prod_qn = input(\"Enter product Quantity: \")\n", 58 | "\n", 59 | "updated_product_lst = []\n", 60 | "\n", 61 | "# Going through each product detail\n", 62 | "for product in products:\n", 63 | " \n", 64 | " prod_details = product.split(',')\n", 65 | " \n", 66 | " if(prod_details[0] == ui_prod_id):\n", 67 | " # Checking if product exists or not\n", 68 | "\n", 69 | " if (int(ui_prod_qn) <= int(prod_details[3])):\n", 70 | " # If we're having enough quantity\n", 71 | " \n", 72 | " print(\"-----------------------------\")\n", 73 | " print(\"Product Name : \", prod_details[1])\n", 74 | " print(\"Price : \", prod_details[2]) \n", 75 | " print(\"Quantity : \", ui_prod_qn) \n", 76 | " print(\"-----------------------------\")\n", 77 | " print(\"Billing Amount : \", int(ui_prod_qn) * int(prod_details[2]))\n", 78 | " print(\"-----------------------------\")\n", 79 | "\n", 80 | " # Updating Inventory list\n", 81 | " prod_details[3] = str(int(prod_details[3]) - int(ui_prod_qn))\n", 82 | " \n", 83 | " # Generating Sales in Sales.txt\n", 84 | " fd = open(\"Sales.txt\",'a')\n", 85 | " sales_detail = ui_username +\",\"+ ui_phone +\",\"+ ui_mail +\",\"+prod_details[1] +\",\"+ ui_prod_id +\",\"+ ui_prod_qn +\",\"+ str(int(ui_prod_qn) * int(prod_details[2]))+\",\"+time.ctime()+ \"\\n\"\n", 86 | " fd.write(sales_detail)\n", 87 | " fd.close()\n", 88 | " \n", 89 | " else:\n", 90 | " # If we're not having enough quantity\n", 91 | " \n", 92 | " print(\"Sorry, We're not having enought quantity.\")\n", 93 | " print(\"We're having only\",prod_details[3],'quantity.')\n", 94 | " print(\"Would you like to purchase it?\")\n", 95 | " \n", 96 | " ch = input(\"Press Y/N: \")\n", 97 | " \n", 98 | " if (ch == 'Y' or ch == 'y'):\n", 99 | " # If you want to purchase with remaining quantity\n", 100 | " \n", 101 | " print(\"-----------------------------\")\n", 102 | " print(\"Product Name : \", prod_details[1])\n", 103 | " print(\"Price : \", prod_details[2]) \n", 104 | " print(\"Quantity : \", prod_details[3]) \n", 105 | " print(\"-----------------------------\")\n", 106 | " print(\"Billing Amount : \", int(prod_details[3]) * int(prod_details[2]))\n", 107 | " print(\"-----------------------------\")\n", 108 | " \n", 109 | " # Updating Inventory list\n", 110 | " prod_details[3] = '0'\n", 111 | "\n", 112 | " else:\n", 113 | " print(\"Thanks\")\n", 114 | " \n", 115 | " # Updating my Inventory List\n", 116 | " updated_product_lst.append(prod_details)\n", 117 | " \n", 118 | "\n", 119 | " \n", 120 | "lst = []\n", 121 | "\n", 122 | "# Updating my Inventory String\n", 123 | "for i in updated_product_lst:\n", 124 | " prod = i[0] +\",\"+ i[1] +\",\"+ i[2] +\",\"+ i[3] + '\\n'\n", 125 | " lst.append(prod)\n", 126 | "\n", 127 | " \n", 128 | "lst[-1] = lst[-1][:-1]\n", 129 | " \n", 130 | "\n", 131 | "# Updating Inventory File\n", 132 | "fd = open('Inventory.txt','w')\n", 133 | "\n", 134 | "for i in lst:\n", 135 | " fd.write(i)\n", 136 | "\n", 137 | "fd.close()\n", 138 | "\n", 139 | "print(\"-------------------\")\n", 140 | "print(\"Inventory Updated\")" 141 | ] 142 | }, 143 | { 144 | "cell_type": "code", 145 | "execution_count": 17, 146 | "id": "fd5b609a", 147 | "metadata": {}, 148 | "outputs": [], 149 | "source": [] 150 | }, 151 | { 152 | "cell_type": "code", 153 | "execution_count": null, 154 | "id": "5276aa90", 155 | "metadata": {}, 156 | "outputs": [], 157 | "source": [] 158 | } 159 | ], 160 | "metadata": { 161 | "kernelspec": { 162 | "display_name": "Python 3", 163 | "language": "python", 164 | "name": "python3" 165 | }, 166 | "language_info": { 167 | "codemirror_mode": { 168 | "name": "ipython", 169 | "version": 3 170 | }, 171 | "file_extension": ".py", 172 | "mimetype": "text/x-python", 173 | "name": "python", 174 | "nbconvert_exporter": "python", 175 | "pygments_lexer": "ipython3", 176 | "version": "3.8.8" 177 | } 178 | }, 179 | "nbformat": 4, 180 | "nbformat_minor": 5 181 | } 182 | -------------------------------------------------------------------------------- /Inventory Management with Files - Generate Sales/Inventory.txt: -------------------------------------------------------------------------------- 1 | 1,5 Star,5,98 2 | 2,Milky Bar,5,195 3 | 3,Cake,300,8 4 | 4,Candy,1,1000 -------------------------------------------------------------------------------- /Inventory Management with Files - Generate Sales/Sales.txt: -------------------------------------------------------------------------------- 1 | Ahsihs,4,324,Cake,3,2,600,Tue Sep 21 02:12:25 2021 2 | -------------------------------------------------------------------------------- /Inventory Management with Files - Overview/Inventory Management - Overview.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "id": "5ab0e1b3", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "fd = open(\"Inventory.txt\",'w')\n", 11 | "\n", 12 | "fd.close()" 13 | ] 14 | }, 15 | { 16 | "cell_type": "markdown", 17 | "id": "23d352a0", 18 | "metadata": {}, 19 | "source": [ 20 | "## Product Details\n", 21 | "1. Product ID\n", 22 | "2. Name of Product\n", 23 | "3. Price of Product\n", 24 | "4. Quantity" 25 | ] 26 | }, 27 | { 28 | "cell_type": "code", 29 | "execution_count": 97, 30 | "id": "053c9d79", 31 | "metadata": {}, 32 | "outputs": [], 33 | "source": [ 34 | "fd = open('Inventory.txt','r')\n", 35 | "\n", 36 | "txt = fd.read()\n", 37 | "\n", 38 | "fd.close()" 39 | ] 40 | }, 41 | { 42 | "cell_type": "code", 43 | "execution_count": 98, 44 | "id": "76d53231", 45 | "metadata": {}, 46 | "outputs": [ 47 | { 48 | "name": "stdout", 49 | "output_type": "stream", 50 | "text": [ 51 | "1,5 Star,5,100\n", 52 | "2,Milky Bar,5,100\n", 53 | "3,Cake,300,5\n", 54 | "4,Candy,1,200\n" 55 | ] 56 | } 57 | ], 58 | "source": [ 59 | "print(txt)" 60 | ] 61 | }, 62 | { 63 | "cell_type": "code", 64 | "execution_count": 99, 65 | "id": "92aaa63f", 66 | "metadata": {}, 67 | "outputs": [ 68 | { 69 | "data": { 70 | "text/plain": [ 71 | "'1,5 Star,5,100\\n2,Milky Bar,5,100\\n3,Cake,300,5\\n4,Candy,1,200'" 72 | ] 73 | }, 74 | "execution_count": 99, 75 | "metadata": {}, 76 | "output_type": "execute_result" 77 | } 78 | ], 79 | "source": [ 80 | "txt" 81 | ] 82 | }, 83 | { 84 | "cell_type": "code", 85 | "execution_count": 100, 86 | "id": "043686d9", 87 | "metadata": {}, 88 | "outputs": [ 89 | { 90 | "data": { 91 | "text/plain": [ 92 | "['1,5 Star,5,100', '2,Milky Bar,5,100', '3,Cake,300,5', '4,Candy,1,200']" 93 | ] 94 | }, 95 | "execution_count": 100, 96 | "metadata": {}, 97 | "output_type": "execute_result" 98 | } 99 | ], 100 | "source": [ 101 | "txt.split('\\n')" 102 | ] 103 | }, 104 | { 105 | "cell_type": "code", 106 | "execution_count": null, 107 | "id": "5919c66a", 108 | "metadata": {}, 109 | "outputs": [], 110 | "source": [] 111 | } 112 | ], 113 | "metadata": { 114 | "kernelspec": { 115 | "display_name": "Python 3", 116 | "language": "python", 117 | "name": "python3" 118 | }, 119 | "language_info": { 120 | "codemirror_mode": { 121 | "name": "ipython", 122 | "version": 3 123 | }, 124 | "file_extension": ".py", 125 | "mimetype": "text/x-python", 126 | "name": "python", 127 | "nbconvert_exporter": "python", 128 | "pygments_lexer": "ipython3", 129 | "version": "3.8.8" 130 | } 131 | }, 132 | "nbformat": 4, 133 | "nbformat_minor": 5 134 | } 135 | -------------------------------------------------------------------------------- /Inventory Management with Files - Overview/Inventory.txt: -------------------------------------------------------------------------------- 1 | 1,5 Star,5,100 2 | 2,Milky Bar,5,100 3 | 3,Cake,300,5 4 | 4,Candy,1,200 -------------------------------------------------------------------------------- /Inventory Management with Files - Product Details/Inventory Management with Files - Product Details.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "52890fc1", 6 | "metadata": {}, 7 | "source": [ 8 | "## Product Details\n", 9 | "1. Product ID\n", 10 | "2. Name of Product\n", 11 | "3. Price of Product\n", 12 | "4. Quantity" 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": 103, 18 | "id": "6ee44bf4", 19 | "metadata": {}, 20 | "outputs": [], 21 | "source": [ 22 | "fd = open('Inventory.txt','r')\n", 23 | "\n", 24 | "products = fd.read().split('\\n')\n", 25 | "\n", 26 | "fd.close()" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 114, 32 | "id": "100a8bde", 33 | "metadata": {}, 34 | "outputs": [ 35 | { 36 | "name": "stdout", 37 | "output_type": "stream", 38 | "text": [ 39 | "1,5 Star,5,100\n", 40 | "2,Milky Bar,5,100\n", 41 | "3,Cake,300,5\n", 42 | "4,Candy,1,200\n" 43 | ] 44 | } 45 | ], 46 | "source": [ 47 | "for i in products:\n", 48 | " print(i)" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": 123, 54 | "id": "d9533d8f", 55 | "metadata": { 56 | "scrolled": true 57 | }, 58 | "outputs": [ 59 | { 60 | "name": "stdout", 61 | "output_type": "stream", 62 | "text": [ 63 | "Enter product ID: 1\n", 64 | "Enter product Quantity: 2\n", 65 | "-----------------------------\n", 66 | "Product Name : 5 Star\n", 67 | "Price : 5\n", 68 | "Quantity : 2\n", 69 | "-----------------------------\n", 70 | "Billing Amount : 10\n", 71 | "-----------------------------\n" 72 | ] 73 | } 74 | ], 75 | "source": [ 76 | "ui_prod_id = input(\"Enter product ID: \")\n", 77 | "ui_prod_qn = input(\"Enter product Quantity: \")\n", 78 | "\n", 79 | "for product in products:\n", 80 | " \n", 81 | " prod_details = product.split(',')\n", 82 | " \n", 83 | " if(prod_details[0] == ui_prod_id):\n", 84 | " print(\"-----------------------------\")\n", 85 | " print(\"Product Name : \", prod_details[1])\n", 86 | " print(\"Price : \", prod_details[2]) \n", 87 | " print(\"Quantity : \", ui_prod_qn) \n", 88 | " print(\"-----------------------------\")\n", 89 | " print(\"Billing Amount : \", int(ui_prod_qn) * int(prod_details[2]))\n", 90 | " print(\"-----------------------------\")" 91 | ] 92 | }, 93 | { 94 | "cell_type": "code", 95 | "execution_count": 99, 96 | "id": "a007666c", 97 | "metadata": {}, 98 | "outputs": [ 99 | { 100 | "data": { 101 | "text/plain": [ 102 | "'1,5 Star,5,100\\n2,Milky Bar,5,100\\n3,Cake,300,5\\n4,Candy,1,200'" 103 | ] 104 | }, 105 | "execution_count": 99, 106 | "metadata": {}, 107 | "output_type": "execute_result" 108 | } 109 | ], 110 | "source": [ 111 | "txt" 112 | ] 113 | }, 114 | { 115 | "cell_type": "code", 116 | "execution_count": 100, 117 | "id": "e38bf06e", 118 | "metadata": {}, 119 | "outputs": [ 120 | { 121 | "data": { 122 | "text/plain": [ 123 | "['1,5 Star,5,100', '2,Milky Bar,5,100', '3,Cake,300,5', '4,Candy,1,200']" 124 | ] 125 | }, 126 | "execution_count": 100, 127 | "metadata": {}, 128 | "output_type": "execute_result" 129 | } 130 | ], 131 | "source": [] 132 | } 133 | ], 134 | "metadata": { 135 | "kernelspec": { 136 | "display_name": "Python 3", 137 | "language": "python", 138 | "name": "python3" 139 | }, 140 | "language_info": { 141 | "codemirror_mode": { 142 | "name": "ipython", 143 | "version": 3 144 | }, 145 | "file_extension": ".py", 146 | "mimetype": "text/x-python", 147 | "name": "python", 148 | "nbconvert_exporter": "python", 149 | "pygments_lexer": "ipython3", 150 | "version": "3.8.8" 151 | } 152 | }, 153 | "nbformat": 4, 154 | "nbformat_minor": 5 155 | } 156 | -------------------------------------------------------------------------------- /Inventory Management with Files - Product Details/Inventory.txt: -------------------------------------------------------------------------------- 1 | 1,5 Star,5,100 2 | 2,Milky Bar,5,100 3 | 3,Cake,300,5 4 | 4,Candy,1,200 -------------------------------------------------------------------------------- /Inventory Management with Files - Updating Inventory/Inventory Management with Files - Updating Inventory.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "id": "7090ccd4", 6 | "metadata": {}, 7 | "source": [ 8 | "## Product Details\n", 9 | "1. Product ID\n", 10 | "2. Name of Product\n", 11 | "3. Price of Product\n", 12 | "4. Quantity" 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": 173, 18 | "id": "e189d341", 19 | "metadata": { 20 | "scrolled": true 21 | }, 22 | "outputs": [ 23 | { 24 | "name": "stdout", 25 | "output_type": "stream", 26 | "text": [ 27 | "Enter product ID: 3\n", 28 | "Enter product Quantity: 5\n", 29 | "-----------------------------\n", 30 | "Product Name : Cake\n", 31 | "Price : 300\n", 32 | "Quantity : 5\n", 33 | "-----------------------------\n", 34 | "Billing Amount : 1500\n", 35 | "-----------------------------\n" 36 | ] 37 | } 38 | ], 39 | "source": [ 40 | "fd = open('Inventory.txt','r')\n", 41 | "products = fd.read().split('\\n')\n", 42 | "fd.close()\n", 43 | "\n", 44 | "\n", 45 | "ui_prod_id = input(\"Enter product ID: \")\n", 46 | "ui_prod_qn = input(\"Enter product Quantity: \")\n", 47 | "\n", 48 | "updated_product_lst = []\n", 49 | "\n", 50 | "for product in products:\n", 51 | " \n", 52 | " prod_details = product.split(',')\n", 53 | " \n", 54 | " if(prod_details[0] == ui_prod_id):\n", 55 | " print(\"-----------------------------\")\n", 56 | " print(\"Product Name : \", prod_details[1])\n", 57 | " print(\"Price : \", prod_details[2]) \n", 58 | " print(\"Quantity : \", ui_prod_qn) \n", 59 | " print(\"-----------------------------\")\n", 60 | " print(\"Billing Amount : \", int(ui_prod_qn) * int(prod_details[2]))\n", 61 | " print(\"-----------------------------\")\n", 62 | " \n", 63 | " prod_details[3] = str(int(prod_details[3]) - int(ui_prod_qn))\n", 64 | " \n", 65 | " updated_product_lst.append(prod_details)\n", 66 | " \n", 67 | "\n", 68 | " \n", 69 | "lst = []\n", 70 | "\n", 71 | "for i in updated_product_lst:\n", 72 | " prod = i[0] +\",\"+ i[1] +\",\"+ i[2] +\",\"+ i[3] + '\\n'\n", 73 | " lst.append(prod)\n", 74 | "\n", 75 | "lst[-1] = lst[-1][:-1]\n", 76 | " \n", 77 | "fd = open('Inventory.txt','w')\n", 78 | "\n", 79 | "for i in lst:\n", 80 | " fd.write(i)\n", 81 | "\n", 82 | "fd.close()" 83 | ] 84 | }, 85 | { 86 | "cell_type": "code", 87 | "execution_count": null, 88 | "id": "fd5b609a", 89 | "metadata": {}, 90 | "outputs": [], 91 | "source": [] 92 | } 93 | ], 94 | "metadata": { 95 | "kernelspec": { 96 | "display_name": "Python 3", 97 | "language": "python", 98 | "name": "python3" 99 | }, 100 | "language_info": { 101 | "codemirror_mode": { 102 | "name": "ipython", 103 | "version": 3 104 | }, 105 | "file_extension": ".py", 106 | "mimetype": "text/x-python", 107 | "name": "python", 108 | "nbconvert_exporter": "python", 109 | "pygments_lexer": "ipython3", 110 | "version": "3.8.8" 111 | } 112 | }, 113 | "nbformat": 4, 114 | "nbformat_minor": 5 115 | } 116 | -------------------------------------------------------------------------------- /Inventory Management with Files - Updating Inventory/Inventory.txt: -------------------------------------------------------------------------------- 1 | 1,5 Star,5,76 2 | 2,Milky Bar,5,98 3 | 3,Cake,300,0 4 | 4,Candy,1,200 -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # File-Handling-and-JSON-GFG 2 | This repository is having all the codes used in Files and JSON with Python Course for GFG 3 | 4 | ### Automating using Numpy 5 | - Getting Started with Files 6 | - Data Writing on Files 7 | - Data Reading from Files 8 | - Text Preprocessing 9 | - Inventory Management using Files 10 | - Getting Started with JSON 11 | - JSON File Handling 12 | - JSON Data Reading 13 | - JSON Data Writing 14 | - Inventory Management using JSON 15 | 16 | ----- 17 | 18 | ### Who am I? 19 | 20 | My name is Ashish Jangra, I make videos about coding and tech. I'm working as a Data Science Mentor at GeeksForGeeks. I am also working as AI trainer at Teenage Coder and Elite Techno Groups. I've made India's first Self Driving Cars course with ETG. I've trained more than 20000 students on different technologies like AI, Data Science, Computer Vision, and Internet of Things. I'm passionate about teaching and giving students the skillset to learn cutting-edge technologies. 21 | 22 | ----- 23 | 24 | ### Other Useful Links: 25 | 26 | LinkedIn - https://linkedin.com/in/ashish-jangra 27 | 28 | Instagram - https://instagram.com/ashish_zangra 29 | 30 | Facebook - https://facebook.com/ashishzangra 31 | -------------------------------------------------------------------------------- /Reading Data from File/Reading Data from File.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 5, 6 | "id": "94dc79f1", 7 | "metadata": {}, 8 | "outputs": [ 9 | { 10 | "name": "stdout", 11 | "output_type": "stream", 12 | "text": [ 13 | "Hello Everyone, How are you?\n" 14 | ] 15 | } 16 | ], 17 | "source": [ 18 | "fd = open('data.txt','r')\n", 19 | "print(fd.read())\n", 20 | "fd.close()" 21 | ] 22 | } 23 | ], 24 | "metadata": { 25 | "kernelspec": { 26 | "display_name": "Python 3", 27 | "language": "python", 28 | "name": "python3" 29 | }, 30 | "language_info": { 31 | "codemirror_mode": { 32 | "name": "ipython", 33 | "version": 3 34 | }, 35 | "file_extension": ".py", 36 | "mimetype": "text/x-python", 37 | "name": "python", 38 | "nbconvert_exporter": "python", 39 | "pygments_lexer": "ipython3", 40 | "version": "3.8.8" 41 | } 42 | }, 43 | "nbformat": 4, 44 | "nbformat_minor": 5 45 | } 46 | -------------------------------------------------------------------------------- /Reading Data from File/data.txt: -------------------------------------------------------------------------------- 1 | Hello Everyone, How are you? -------------------------------------------------------------------------------- /Reading Data from Text-file Corpus/Reading Data from Text-file Corpus.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 11, 6 | "id": "2072bec2", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "fd = open('data.txt','r')\n", 11 | "txt = fd.read()\n", 12 | "fd.close()" 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": 12, 18 | "id": "a29fda39", 19 | "metadata": {}, 20 | "outputs": [ 21 | { 22 | "data": { 23 | "text/plain": [ 24 | "\"Coronavirus disease 2019 (COVID-19) is a contagious disease caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2). The first known case was identified in Wuhan, China, in December 2019.[7] The disease has since spread worldwide, leading to an ongoing pandemic.[8]\\n\\nSymptoms of COVID-19 are variable, but often include fever,[9] cough, headache,[10] fatigue, breathing difficulties, and loss of smell and taste.[11][12][13] Symptoms may begin one to fourteen days after exposure to the virus. At least a third of people who are infected do not develop noticeable symptoms.[14] Of those people who develop symptoms noticeable enough to be classed as patients, most (81%) develop mild to moderate symptoms (up to mild pneumonia), while 14% develop severe symptoms (dyspnea, hypoxia, or more than 50% lung involvement on imaging), and 5% suffer critical symptoms (respiratory failure, shock, or multi-organ dysfunction).[15] Older people are at a higher risk of developing severe symptoms. Some people continue to experience a range of effects (long COVID) for months after recovery, and damage to organs has been observed.[16] Multi-year studies are underway to further investigate the long-term effects of the disease.[16]\\n\\nCOVID-19 transmits when people breathe in air contaminated by droplets and small airborne particles containing the virus. The risk of breathing these in is highest when people are in close proximity, but they can be inhaled over longer distances, particularly indoors. Transmission can also occur if splashed or sprayed with contaminated fluids in the eyes, nose or mouth, and, rarely, via contaminated surfaces. People remain contagious for up to 20 days, and can spread the virus even if they do not develop symptoms.[17][18]\\n\\nSeveral testing methods have been developed to diagnose the disease. The standard diagnostic method is by detection of the virus' nucleic acid by real-time reverse transcription polymerase chain reaction (rRT-PCR), transcription-mediated amplification (TMA), or by reverse transcription loop-mediated isothermal amplification (RT-LAMP) from a nasopharyngeal swab.\\n\\nPreventive measures include physical or social distancing, quarantining, ventilation of indoor spaces, covering coughs and sneezes, hand washing, and keeping unwashed hands away from the face. The use of face masks or coverings has been recommended in public settings to minimise the risk of transmissions.\\n\\nWhile work is underway to develop drugs that inhibit the virus (and several vaccines for it have been approved and distributed in various countries, which have since initiated mass vaccination campaigns), the primary treatment is symptomatic. Management involves the treatment of symptoms, supportive care, isolation, and experimental measures.\"" 25 | ] 26 | }, 27 | "execution_count": 12, 28 | "metadata": {}, 29 | "output_type": "execute_result" 30 | } 31 | ], 32 | "source": [ 33 | "txt" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": 14, 39 | "id": "d7c1b558", 40 | "metadata": {}, 41 | "outputs": [], 42 | "source": [ 43 | "txt = txt.replace(\"\\n\\n\",' ')" 44 | ] 45 | }, 46 | { 47 | "cell_type": "code", 48 | "execution_count": 15, 49 | "id": "9aaa3da8", 50 | "metadata": {}, 51 | "outputs": [ 52 | { 53 | "name": "stdout", 54 | "output_type": "stream", 55 | "text": [ 56 | "Coronavirus disease 2019 (COVID-19) is a contagious disease caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2). The first known case was identified in Wuhan, China, in December 2019.[7] The disease has since spread worldwide, leading to an ongoing pandemic.[8] Symptoms of COVID-19 are variable, but often include fever,[9] cough, headache,[10] fatigue, breathing difficulties, and loss of smell and taste.[11][12][13] Symptoms may begin one to fourteen days after exposure to the virus. At least a third of people who are infected do not develop noticeable symptoms.[14] Of those people who develop symptoms noticeable enough to be classed as patients, most (81%) develop mild to moderate symptoms (up to mild pneumonia), while 14% develop severe symptoms (dyspnea, hypoxia, or more than 50% lung involvement on imaging), and 5% suffer critical symptoms (respiratory failure, shock, or multi-organ dysfunction).[15] Older people are at a higher risk of developing severe symptoms. Some people continue to experience a range of effects (long COVID) for months after recovery, and damage to organs has been observed.[16] Multi-year studies are underway to further investigate the long-term effects of the disease.[16] COVID-19 transmits when people breathe in air contaminated by droplets and small airborne particles containing the virus. The risk of breathing these in is highest when people are in close proximity, but they can be inhaled over longer distances, particularly indoors. Transmission can also occur if splashed or sprayed with contaminated fluids in the eyes, nose or mouth, and, rarely, via contaminated surfaces. People remain contagious for up to 20 days, and can spread the virus even if they do not develop symptoms.[17][18] Several testing methods have been developed to diagnose the disease. The standard diagnostic method is by detection of the virus' nucleic acid by real-time reverse transcription polymerase chain reaction (rRT-PCR), transcription-mediated amplification (TMA), or by reverse transcription loop-mediated isothermal amplification (RT-LAMP) from a nasopharyngeal swab. Preventive measures include physical or social distancing, quarantining, ventilation of indoor spaces, covering coughs and sneezes, hand washing, and keeping unwashed hands away from the face. The use of face masks or coverings has been recommended in public settings to minimise the risk of transmissions. While work is underway to develop drugs that inhibit the virus (and several vaccines for it have been approved and distributed in various countries, which have since initiated mass vaccination campaigns), the primary treatment is symptomatic. Management involves the treatment of symptoms, supportive care, isolation, and experimental measures.\n" 57 | ] 58 | } 59 | ], 60 | "source": [ 61 | "print(txt)" 62 | ] 63 | }, 64 | { 65 | "cell_type": "code", 66 | "execution_count": null, 67 | "id": "2a4288b6", 68 | "metadata": {}, 69 | "outputs": [], 70 | "source": [] 71 | } 72 | ], 73 | "metadata": { 74 | "kernelspec": { 75 | "display_name": "Python 3", 76 | "language": "python", 77 | "name": "python3" 78 | }, 79 | "language_info": { 80 | "codemirror_mode": { 81 | "name": "ipython", 82 | "version": 3 83 | }, 84 | "file_extension": ".py", 85 | "mimetype": "text/x-python", 86 | "name": "python", 87 | "nbconvert_exporter": "python", 88 | "pygments_lexer": "ipython3", 89 | "version": "3.8.8" 90 | } 91 | }, 92 | "nbformat": 4, 93 | "nbformat_minor": 5 94 | } 95 | -------------------------------------------------------------------------------- /Reading Data from Text-file Corpus/data.txt: -------------------------------------------------------------------------------- 1 | Coronavirus disease 2019 (COVID-19) is a contagious disease caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2). The first known case was identified in Wuhan, China, in December 2019.[7] The disease has since spread worldwide, leading to an ongoing pandemic.[8] 2 | 3 | Symptoms of COVID-19 are variable, but often include fever,[9] cough, headache,[10] fatigue, breathing difficulties, and loss of smell and taste.[11][12][13] Symptoms may begin one to fourteen days after exposure to the virus. At least a third of people who are infected do not develop noticeable symptoms.[14] Of those people who develop symptoms noticeable enough to be classed as patients, most (81%) develop mild to moderate symptoms (up to mild pneumonia), while 14% develop severe symptoms (dyspnea, hypoxia, or more than 50% lung involvement on imaging), and 5% suffer critical symptoms (respiratory failure, shock, or multi-organ dysfunction).[15] Older people are at a higher risk of developing severe symptoms. Some people continue to experience a range of effects (long COVID) for months after recovery, and damage to organs has been observed.[16] Multi-year studies are underway to further investigate the long-term effects of the disease.[16] 4 | 5 | COVID-19 transmits when people breathe in air contaminated by droplets and small airborne particles containing the virus. The risk of breathing these in is highest when people are in close proximity, but they can be inhaled over longer distances, particularly indoors. Transmission can also occur if splashed or sprayed with contaminated fluids in the eyes, nose or mouth, and, rarely, via contaminated surfaces. People remain contagious for up to 20 days, and can spread the virus even if they do not develop symptoms.[17][18] 6 | 7 | Several testing methods have been developed to diagnose the disease. The standard diagnostic method is by detection of the virus' nucleic acid by real-time reverse transcription polymerase chain reaction (rRT-PCR), transcription-mediated amplification (TMA), or by reverse transcription loop-mediated isothermal amplification (RT-LAMP) from a nasopharyngeal swab. 8 | 9 | Preventive measures include physical or social distancing, quarantining, ventilation of indoor spaces, covering coughs and sneezes, hand washing, and keeping unwashed hands away from the face. The use of face masks or coverings has been recommended in public settings to minimise the risk of transmissions. 10 | 11 | While work is underway to develop drugs that inhibit the virus (and several vaccines for it have been approved and distributed in various countries, which have since initiated mass vaccination campaigns), the primary treatment is symptomatic. Management involves the treatment of symptoms, supportive care, isolation, and experimental measures. -------------------------------------------------------------------------------- /Text Preprocessing/Text Preprocessing.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 19, 6 | "id": "ac93a327", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "fd = open('data.txt','r')\n", 11 | "txt = fd.read()\n", 12 | "fd.close()" 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": 20, 18 | "id": "da57a0ac", 19 | "metadata": {}, 20 | "outputs": [ 21 | { 22 | "data": { 23 | "text/plain": [ 24 | "\"Coronavirus disease 2019 (COVID-19) is a contagious disease caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2). The first known case was identified in Wuhan, China, in December 2019.[7] The disease has since spread worldwide, leading to an ongoing pandemic.[8]\\n\\nSymptoms of COVID-19 are variable, but often include fever,[9] cough, headache,[10] fatigue, breathing difficulties, and loss of smell and taste.[11][12][13] Symptoms may begin one to fourteen days after exposure to the virus. At least a third of people who are infected do not develop noticeable symptoms.[14] Of those people who develop symptoms noticeable enough to be classed as patients, most (81%) develop mild to moderate symptoms (up to mild pneumonia), while 14% develop severe symptoms (dyspnea, hypoxia, or more than 50% lung involvement on imaging), and 5% suffer critical symptoms (respiratory failure, shock, or multi-organ dysfunction).[15] Older people are at a higher risk of developing severe symptoms. Some people continue to experience a range of effects (long COVID) for months after recovery, and damage to organs has been observed.[16] Multi-year studies are underway to further investigate the long-term effects of the disease.[16]\\n\\nCOVID-19 transmits when people breathe in air contaminated by droplets and small airborne particles containing the virus. The risk of breathing these in is highest when people are in close proximity, but they can be inhaled over longer distances, particularly indoors. Transmission can also occur if splashed or sprayed with contaminated fluids in the eyes, nose or mouth, and, rarely, via contaminated surfaces. People remain contagious for up to 20 days, and can spread the virus even if they do not develop symptoms.[17][18]\\n\\nSeveral testing methods have been developed to diagnose the disease. The standard diagnostic method is by detection of the virus' nucleic acid by real-time reverse transcription polymerase chain reaction (rRT-PCR), transcription-mediated amplification (TMA), or by reverse transcription loop-mediated isothermal amplification (RT-LAMP) from a nasopharyngeal swab.\\n\\nPreventive measures include physical or social distancing, quarantining, ventilation of indoor spaces, covering coughs and sneezes, hand washing, and keeping unwashed hands away from the face. The use of face masks or coverings has been recommended in public settings to minimise the risk of transmissions.\\n\\nWhile work is underway to develop drugs that inhibit the virus (and several vaccines for it have been approved and distributed in various countries, which have since initiated mass vaccination campaigns), the primary treatment is symptomatic. Management involves the treatment of symptoms, supportive care, isolation, and experimental measures.\"" 25 | ] 26 | }, 27 | "execution_count": 20, 28 | "metadata": {}, 29 | "output_type": "execute_result" 30 | } 31 | ], 32 | "source": [ 33 | "txt" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": 22, 39 | "id": "bf8d582f", 40 | "metadata": { 41 | "scrolled": true 42 | }, 43 | "outputs": [ 44 | { 45 | "name": "stdout", 46 | "output_type": "stream", 47 | "text": [ 48 | "Coronavirus disease 2019 (COVID-19) is a contagious disease caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2). The first known case was identified in Wuhan, China, in December 2019.[7] The disease has since spread worldwide, leading to an ongoing pandemic.[8]\n", 49 | "\n", 50 | "Symptoms of COVID-19 are variable, but often include fever,[9] cough, headache,[10] fatigue, breathing difficulties, and loss of smell and taste.[11][12][13] Symptoms may begin one to fourteen days after exposure to the virus. At least a third of people who are infected do not develop noticeable symptoms.[14] Of those people who develop symptoms noticeable enough to be classed as patients, most (81%) develop mild to moderate symptoms (up to mild pneumonia), while 14% develop severe symptoms (dyspnea, hypoxia, or more than 50% lung involvement on imaging), and 5% suffer critical symptoms (respiratory failure, shock, or multi-organ dysfunction).[15] Older people are at a higher risk of developing severe symptoms. Some people continue to experience a range of effects (long COVID) for months after recovery, and damage to organs has been observed.[16] Multi-year studies are underway to further investigate the long-term effects of the disease.[16]\n", 51 | "\n", 52 | "COVID-19 transmits when people breathe in air contaminated by droplets and small airborne particles containing the virus. The risk of breathing these in is highest when people are in close proximity, but they can be inhaled over longer distances, particularly indoors. Transmission can also occur if splashed or sprayed with contaminated fluids in the eyes, nose or mouth, and, rarely, via contaminated surfaces. People remain contagious for up to 20 days, and can spread the virus even if they do not develop symptoms.[17][18]\n", 53 | "\n", 54 | "Several testing methods have been developed to diagnose the disease. The standard diagnostic method is by detection of the virus' nucleic acid by real-time reverse transcription polymerase chain reaction (rRT-PCR), transcription-mediated amplification (TMA), or by reverse transcription loop-mediated isothermal amplification (RT-LAMP) from a nasopharyngeal swab.\n", 55 | "\n", 56 | "Preventive measures include physical or social distancing, quarantining, ventilation of indoor spaces, covering coughs and sneezes, hand washing, and keeping unwashed hands away from the face. The use of face masks or coverings has been recommended in public settings to minimise the risk of transmissions.\n", 57 | "\n", 58 | "While work is underway to develop drugs that inhibit the virus (and several vaccines for it have been approved and distributed in various countries, which have since initiated mass vaccination campaigns), the primary treatment is symptomatic. Management involves the treatment of symptoms, supportive care, isolation, and experimental measures.\n" 59 | ] 60 | } 61 | ], 62 | "source": [ 63 | "print(txt)" 64 | ] 65 | }, 66 | { 67 | "cell_type": "markdown", 68 | "id": "115cd3a5", 69 | "metadata": {}, 70 | "source": [ 71 | "## Peragraphs" 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": 32, 77 | "id": "c9b49a18", 78 | "metadata": {}, 79 | "outputs": [ 80 | { 81 | "name": "stdout", 82 | "output_type": "stream", 83 | "text": [ 84 | "6\n" 85 | ] 86 | } 87 | ], 88 | "source": [ 89 | "per = txt.split(\"\\n\\n\")\n", 90 | "print(len(per))" 91 | ] 92 | }, 93 | { 94 | "cell_type": "markdown", 95 | "id": "42de5aff", 96 | "metadata": {}, 97 | "source": [ 98 | "## Lines" 99 | ] 100 | }, 101 | { 102 | "cell_type": "code", 103 | "execution_count": 35, 104 | "id": "569d1bbe", 105 | "metadata": {}, 106 | "outputs": [], 107 | "source": [ 108 | "lines = txt.split(\".\")" 109 | ] 110 | }, 111 | { 112 | "cell_type": "code", 113 | "execution_count": 41, 114 | "id": "d352f3fd", 115 | "metadata": {}, 116 | "outputs": [ 117 | { 118 | "data": { 119 | "text/plain": [ 120 | "20" 121 | ] 122 | }, 123 | "execution_count": 41, 124 | "metadata": {}, 125 | "output_type": "execute_result" 126 | } 127 | ], 128 | "source": [ 129 | "len(lines[:-1])" 130 | ] 131 | }, 132 | { 133 | "cell_type": "markdown", 134 | "id": "0a3fdde6", 135 | "metadata": {}, 136 | "source": [ 137 | "## Words" 138 | ] 139 | }, 140 | { 141 | "cell_type": "code", 142 | "execution_count": 43, 143 | "id": "1bdcbe29", 144 | "metadata": {}, 145 | "outputs": [], 146 | "source": [ 147 | "words = txt.split(\" \")" 148 | ] 149 | }, 150 | { 151 | "cell_type": "code", 152 | "execution_count": 45, 153 | "id": "26b3f90b", 154 | "metadata": {}, 155 | "outputs": [ 156 | { 157 | "data": { 158 | "text/plain": [ 159 | "398" 160 | ] 161 | }, 162 | "execution_count": 45, 163 | "metadata": {}, 164 | "output_type": "execute_result" 165 | } 166 | ], 167 | "source": [ 168 | "len(words)" 169 | ] 170 | }, 171 | { 172 | "cell_type": "code", 173 | "execution_count": null, 174 | "id": "0142e05f", 175 | "metadata": {}, 176 | "outputs": [], 177 | "source": [] 178 | } 179 | ], 180 | "metadata": { 181 | "kernelspec": { 182 | "display_name": "Python 3", 183 | "language": "python", 184 | "name": "python3" 185 | }, 186 | "language_info": { 187 | "codemirror_mode": { 188 | "name": "ipython", 189 | "version": 3 190 | }, 191 | "file_extension": ".py", 192 | "mimetype": "text/x-python", 193 | "name": "python", 194 | "nbconvert_exporter": "python", 195 | "pygments_lexer": "ipython3", 196 | "version": "3.8.8" 197 | } 198 | }, 199 | "nbformat": 4, 200 | "nbformat_minor": 5 201 | } 202 | -------------------------------------------------------------------------------- /Text Preprocessing/data.txt: -------------------------------------------------------------------------------- 1 | Coronavirus disease 2019 (COVID-19) is a contagious disease caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2). The first known case was identified in Wuhan, China, in December 2019.[7] The disease has since spread worldwide, leading to an ongoing pandemic.[8] 2 | 3 | Symptoms of COVID-19 are variable, but often include fever,[9] cough, headache,[10] fatigue, breathing difficulties, and loss of smell and taste.[11][12][13] Symptoms may begin one to fourteen days after exposure to the virus. At least a third of people who are infected do not develop noticeable symptoms.[14] Of those people who develop symptoms noticeable enough to be classed as patients, most (81%) develop mild to moderate symptoms (up to mild pneumonia), while 14% develop severe symptoms (dyspnea, hypoxia, or more than 50% lung involvement on imaging), and 5% suffer critical symptoms (respiratory failure, shock, or multi-organ dysfunction).[15] Older people are at a higher risk of developing severe symptoms. Some people continue to experience a range of effects (long COVID) for months after recovery, and damage to organs has been observed.[16] Multi-year studies are underway to further investigate the long-term effects of the disease.[16] 4 | 5 | COVID-19 transmits when people breathe in air contaminated by droplets and small airborne particles containing the virus. The risk of breathing these in is highest when people are in close proximity, but they can be inhaled over longer distances, particularly indoors. Transmission can also occur if splashed or sprayed with contaminated fluids in the eyes, nose or mouth, and, rarely, via contaminated surfaces. People remain contagious for up to 20 days, and can spread the virus even if they do not develop symptoms.[17][18] 6 | 7 | Several testing methods have been developed to diagnose the disease. The standard diagnostic method is by detection of the virus' nucleic acid by real-time reverse transcription polymerase chain reaction (rRT-PCR), transcription-mediated amplification (TMA), or by reverse transcription loop-mediated isothermal amplification (RT-LAMP) from a nasopharyngeal swab. 8 | 9 | Preventive measures include physical or social distancing, quarantining, ventilation of indoor spaces, covering coughs and sneezes, hand washing, and keeping unwashed hands away from the face. The use of face masks or coverings has been recommended in public settings to minimise the risk of transmissions. 10 | 11 | While work is underway to develop drugs that inhibit the virus (and several vaccines for it have been approved and distributed in various countries, which have since initiated mass vaccination campaigns), the primary treatment is symptomatic. Management involves the treatment of symptoms, supportive care, isolation, and experimental measures. -------------------------------------------------------------------------------- /Writing Data on a text-file with New Line/Data.txt: -------------------------------------------------------------------------------- 1 | Hello everyone, I'm hoping you guys are doing great as always. 2 | Today we're going to discuss about File Handling. 3 | It's going to be used when you want to save your data permanently. 4 | -------------------------------------------------------------------------------- /Writing Data on a text-file with New Line/Writing Data on a text-file with New Line.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 83, 6 | "id": "51327c62", 7 | "metadata": {}, 8 | "outputs": [ 9 | { 10 | "name": "stdout", 11 | "output_type": "stream", 12 | "text": [ 13 | "Enter the text: Its going to be used when you want to save your data permanently\n" 14 | ] 15 | } 16 | ], 17 | "source": [ 18 | "fd = open(\"Data.txt\",'a')\n", 19 | "\n", 20 | "\n", 21 | "txt = input(\"Enter the text: \")\n", 22 | "txt = txt + '.\\n'\n", 23 | "\n", 24 | "fd.write(txt)\n", 25 | "\n", 26 | "fd.close()" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": null, 32 | "id": "e327623d", 33 | "metadata": {}, 34 | "outputs": [], 35 | "source": [] 36 | } 37 | ], 38 | "metadata": { 39 | "kernelspec": { 40 | "display_name": "Python 3", 41 | "language": "python", 42 | "name": "python3" 43 | }, 44 | "language_info": { 45 | "codemirror_mode": { 46 | "name": "ipython", 47 | "version": 3 48 | }, 49 | "file_extension": ".py", 50 | "mimetype": "text/x-python", 51 | "name": "python", 52 | "nbconvert_exporter": "python", 53 | "pygments_lexer": "ipython3", 54 | "version": "3.8.8" 55 | } 56 | }, 57 | "nbformat": 4, 58 | "nbformat_minor": 5 59 | } 60 | -------------------------------------------------------------------------------- /Writing Data on a text-file/Data.txt: -------------------------------------------------------------------------------- 1 | Hello Everyone, Ashish this side. -------------------------------------------------------------------------------- /Writing Data on a text-file/Writing Data on a text-file.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 75, 6 | "id": "08fb4d45", 7 | "metadata": {}, 8 | "outputs": [], 9 | "source": [ 10 | "fd = open(\"Data.txt\",'w')\n", 11 | "\n", 12 | "\n", 13 | "fd.write(\"Hello Everyone, Ashish this side.\")\n", 14 | "\n", 15 | "fd.close()" 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": null, 21 | "id": "30082956", 22 | "metadata": {}, 23 | "outputs": [], 24 | "source": [] 25 | } 26 | ], 27 | "metadata": { 28 | "kernelspec": { 29 | "display_name": "Python 3", 30 | "language": "python", 31 | "name": "python3" 32 | }, 33 | "language_info": { 34 | "codemirror_mode": { 35 | "name": "ipython", 36 | "version": 3 37 | }, 38 | "file_extension": ".py", 39 | "mimetype": "text/x-python", 40 | "name": "python", 41 | "nbconvert_exporter": "python", 42 | "pygments_lexer": "ipython3", 43 | "version": "3.8.8" 44 | } 45 | }, 46 | "nbformat": 4, 47 | "nbformat_minor": 5 48 | } 49 | --------------------------------------------------------------------------------