Home > Enterprise >  Using one excel column on two places JSON
Using one excel column on two places JSON

Time:12-19

I have Excel file which I am converting to JSON and merge with existing JSON file. The case is that In Excel I have column "ja" and values in it. IS there a way to add values from that column in JSON, on two places: "ja" and "ja-jpn" Expected output:

"ja":{
    "Ball":"Ball",
    "Snow":"Schnee",
    "Elephant":"Elephant",
    "Woman":"Frau",
    "Potato":"Kartoffeln",
    "Tomato":"F",
    "Carrot":"G"
  },
  "ja-jpa":{
    Ball":"Ball",
    "Snow":"Schnee",
    "Elephant":"Elephant",
    "Woman":"Frau",
    "Potato":"Kartoffeln",
    "Tomato":"F",
    "Carrot":"G"
  }

CodePudding user response:

Before you convert your dataframe to JSON, just duplicate the column, like this:

if 'ja' in new_data.columns:
    new_data['ja-jpn'] = new_data['ja']
  • Related