<jupyter_start><jupyter_text>Reading record.json file<jupyter_code>fd = open("record.json","r")
txt = fd.read()
fd.close()<jupyter_output><empty_output><jupyter_text>Printing the txt file<jupyter_code>txt<jupyter_output><empty_output><jupyter_text>Importing json library and converting into a dictionary<jupyter_code>import json
record  = json.loads(txt)
record<jupyter_output><empty_output><jupyter_text>Giving the details to the new item to be added to inventory<jupyter_code>prod_id = input("Enter the id : ")
name = input("Enter the name of the product : ")
mft_date = input("Enter the manufacturing date :")
qty = int(input("Enter the quantity :"))
price = int(input("Enter the price : "))
discount = int(input("Enter the discount : "))<jupyter_output>Enter the id : 11602291
Enter the name of the product : ZARA
Enter the manufacturing date :25-03-2021
Enter the quantity :80
Enter the price : 270
Enter the discount : 30<jupyter_text>Adding new item to the inventory<jupyter_code>record[prod_id] = {'Name': name , 'Mft. Date': mft_date , 'Qty': qty ,  'Price' : price , 'Discount': discount}<jupyter_output><empty_output><jupyter_text>Printing the record with the new item added<jupyter_code>record<jupyter_output><empty_output><jupyter_text>Checking if the qty of a given is  same as that of the qty being given as an input<jupyter_code>id = input("Enter the id : ")
qty = int(input("Enter the qty : "))
for id in record:
    if qty != record[id]['Qty']:
        new_qty = record[id]['Qty'] + qty
        break
    else:
        new_qty = record[id]['Qty']
        break<jupyter_output>Enter the id : 11602260
Enter the qty : 90<jupyter_text>Updating the record with the new qty value to the item<jupyter_code>record[id]['Qty'] = new_qty<jupyter_output><empty_output><jupyter_text>Printing the record with the new value of qty for the item<jupyter_code>record<jupyter_output><empty_output><jupyter_text>Checking if the price given as input  is same as that of item price in the dictionary<jupyter_code>id = input("Enter the id :")
price = int(input("Enter the price : "))
if id in record:
    if price != record[id]['Price']:
        new_price = record[id]['Price'] + price
    else:
        new_price = record[id]['Price']
else:
    print("Invalid Input")<jupyter_output>Enter the id :11602260
Enter the price : 10<jupyter_text>Updating the price in the dictionary<jupyter_code>record[id]['Price'] = new_price<jupyter_output><empty_output><jupyter_text>Printing the dictionary with updated price<jupyter_code>record<jupyter_output><empty_output><jupyter_text>Checking if the discount given as input is same as that of item price in the dictionary<jupyter_code>id = input("Enter the id :")
disc = int(input("Enter the discount :"))
if id in record:
    if disc != record[id]['Discount']:
        disc_price = record[id]['Discount'] + disc
    else:
        disc_price = record[id]['Discount']
else:
    print("Invalid input")<jupyter_output>Enter the id :11602260
Enter the discount :30<jupyter_text>Updating the value of discount to dictionary<jupyter_code>record[id]['Discount'] = disc_price<jupyter_output><empty_output><jupyter_text>Printing the dictionary with the updated value of discount<jupyter_code>record<jupyter_output><empty_output><jupyter_text>Updating the inventory<jupyter_code>js = json.dumps(record)
fd = open("record.json","w")
fd.write(js)
fd.close()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11557641537107656, 'fraction_numerical': 0.015547081255500146, 'mean_word_length': 6.118997912317328, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '16', 'dir': 'jupyter-structured-clean-dedup', 'id': '95161', 'license': 'MIT', 'n_tokens_mistral': 1202, 'n_tokens_neox': 1163, 'n_words': 304, 'path': 'Contributions/Inventory Management System/WARDROBE IMS USING JSON - ADDING NEW ITEMS.ipynb', 'repo_name': 'Mgs25/Hacktoberfest2021-1', 'size': '3409'}