1

I have a JSON Data,

[[{'Design Project': 'Not Available',
   'Design Target*': 'Not Available',
   'Median Property*': '50',
   'Metric': 'ENERGY STAR score (1-100)'},
  {'Design Project': 'Not Available',
   'Design Target*': '35.4',
   'Median Property*': '141.4',
   'Metric': 'Source EUI (kBtu/ft²)'},
  {'Design Project': 'Not Available',
   'Design Target*': '15.8',
   'Median Property*': '63.1',
   'Metric': 'Site EUI (kBtu/ft²)'},
  {'Design Project': 'Not Available',
   'Design Target*': '3,536.0',
   'Median Property*': '14,144.1',
   'Metric': 'Source Energy Use (kBtu)'},
  {'Design Project': 'Not Available',
   'Design Target*': '1,578.7',
   'Median Property*': '6,314.9',
   'Metric': 'Site Energy Use (kBtu)'},
  {'Design Project': 'Not Available',
   'Design Target*': '34.61',
   'Median Property*': '138.44',
   'Metric': 'Energy Cost ($)'},
  {'Design Project': '0.0',
   'Design Target*': '0.2',
   'Median Property*': '0.6',
   'Metric': 'Total GHG Emissions (Metric Tons CO2e)'}],
 [{'Energy Type': ['Energy Not Entered',
                   'Assumed Mix Based on State & Property Type:',
                   '',
                   'Electric - Grid (56.9%)',
                   'Natural Gas (43.1%)'],
   'Target': ' Target % Better than Median: 75',
   'Title': "About this Property's Design",
   'Uses:': 'Other - Education (100.0%)'}],
 [{'Your Design Score ': ' N/A'}]]

I want to remove the Key from the Json because in my Postgres table, key is my column. I want to insert the value to my column.

I would like to do it using Python.

4
  • What is the Key? Commented Nov 24, 2017 at 3:10
  • For example Metric is one key Commented Nov 24, 2017 at 3:11
  • So, do you want to data to look something like this? ['ENERGY STAR score (1-100)', 'Not Available', ...] Commented Nov 24, 2017 at 3:40
  • @DheerajNair yes Commented Nov 24, 2017 at 4:39

1 Answer 1

1
def f(l_of_l_of_ds):
    return [list(l2.values())
            for l1 in l_of_l_of_ds
            for l2 in l1]

Which yields:

[['Not Available', 'Not Available', '50', 'ENERGY STAR score (1-100)'],
 ['Not Available', '35.4', '141.4', 'Source EUI (kBtu/ft²)'],
 ['Not Available', '15.8', '63.1', 'Site EUI (kBtu/ft²)'],
 ['Not Available', '3,536.0', '14,144.1', 'Source Energy Use (kBtu)'],
 ['Not Available', '1,578.7', '6,314.9', 'Site Energy Use (kBtu)'],
 ['Not Available', '34.61', '138.44', 'Energy Cost ($)'],
 ['0.0', '0.2', '0.6', 'Total GHG Emissions (Metric Tons CO2e)'],
 [['Energy Not Entered',
   'Assumed Mix Based on State & Property Type:',
   '',
   'Electric - Grid (56.9%)',
   'Natural Gas (43.1%)'],
  ' Target % Better than Median: 75',
  "About this Property's Design",
  'Other - Education (100.0%)'],
 [' N/A']]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.