![]() |
Not Getting the Desired value using json.dumps - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Not Getting the Desired value using json.dumps (/thread-24192.html) |
Not Getting the Desired value using json.dumps - saurabh210 - Feb-03-2020 I am Trying to make a small code which will take values from excel and make a json file . I get the desired output except 1 issue . Below is my Code ********************** import json from openpyxl import load_workbook print("") path = "output.xlsx" wb=load_workbook(path) Sheet1 = wb.active max_row=Sheet1.max_row max_column=Sheet1.max_column for i in range(2, max_column+1): listing = [] for j in range(2, max_row+1): dictonery = {} dictonery["ParameterKey"] = (Sheet1.cell(j,1)).value dictonery["ParameterValue"] = (Sheet1.cell(j,i)).value listing.append(dictonery) print(json.dumps(listing,indent = 4, sort_keys=True))********************************** output i am getting for print(listing): *************************************************Till here everything is good As you see above The last ParameterValue is "" but But when i run the last line i.e print(json.dumps(listing,indent = 4, sort_keys=True)) the last ParameterValue i am getting "\"\"" (Below Output) Below is the output of print(json.dumps(listing,indent = 4, sort_keys=True)) ************************************************** The JSON Output i need is with last ParamterValue as "" only . can some please helpme ?
|