Downloading ERA5-Land to get daily total precipitataion - cdo-climate

I am trying to understand on what #Rainfall.NZ saying on this answer: https://stackoverflow.com/a/67258594 related to ERA5-Land Hourly precipitation and ERA5 Reanalysis Hourly precipitation are different. See https://confluence.ecmwf.int/pages/viewpage.action?pageId=197702790
From above link, row 5 column 7:
tp [mm]=tpd+1 00UTC [m]⋅1000
where d is the day for which the average flux is being computed.
The time step labelled d+1 00UTC should also be taken because it contains the accumulated flux over the previous 24 hours.
I want to make sure if the step below is correct to get daily total precipitation:
Download the data using API, which include time 00:00 and 23:00 only using below script
import cdsapi
c = cdsapi.Client()
years = list(range(1950, 2021))
for year in years:
c.retrieve(
'reanalysis-era5-land',
{
'variable': [
'total_precipitation',
],
'year': str(year),
'month': [
'01', '02', '03',
'04', '05', '06',
'07', '08', '09',
'10', '11', '12',
],
'day': [
'01', '02', '03',
'04', '05', '06',
'07', '08', '09',
'10', '11', '12',
'13', '14', '15',
'16', '17', '18',
'19', '20', '21',
'22', '23', '24',
'25', '26', '27',
'28', '29', '30',
'31',
],
'time': [
'00:00', '23:00',
],
'area': [
11, 90, -13,
145,
],
'format': 'netcdf',
},
'era5land_' + str(year) + '.nc')
print('era5land_' + str(year) + '.nc' + ' downloaded.')
Using CDO shifttime to get the daily total
cdo daysum -shifttime,-1hour era5land_precip.nc4 temp.nc4
cdo -shifttime,1hour temp.nc4 era5land_precip.nc4

After read carefully from #rainfall.nz post and the documentation, I think I only need to download for hour 00, and do cdo -shifttime,-1hour in.nc out.nc
I also tested by downloading all hourly data for 3 consecutive days and found the data on day3_00 is the total rainfall for 24h for day2.

Related

Is there a way to test PySpark Regex's?

I'd like to test different inputs to a PySpark regex to see if they fail/succeed before running a build. Is there a way to test this in Foundry before running a full build/checks?
You can downsample your input using the Preview functionality in Authoring, where you can then specify a filter you want to craft your input for testing.
Then, you can run your PySpark code on this custom sample to verify it does what you expect.
You click on the gear in the following view after clicking the Preview button.
Then, you can describe what sample you want.
After you have this, running your regex on your input will be fast and easy to test.
I am also a fan of writing unit tests. Create a small input df, desired output df, and write a simple function that takes the input, applies the regex, and returns the output.
import pytest
from datetime import date
import pandas as pd # noqa
import numpy as np
from myproject.analysis.simple_discount import (
calc
)
columns = [
"date",
"id",
"other",
"brand",
"grp_id",
"amounth",
"pct",
"max_amount",
"unit",
"total_units"
]
output_columns = [
"date",
"id",
"other",
"brand",
"grp_id",
"amount",
"pct",
"max_amount",
"qty",
"total_amount"
]
#pytest.fixture
def input_df(spark_session):
data = [
['4/1/21', 'a', '1', 'mn', '567', 0.54, 50, 1.08, 1.08, 1],
['4/1/21', 'a', '1', 'mn', '567', 0.54, 50, 1.08, 1.08, 1],
['4/1/21', 'a', '1', 'mn', '567', 0.54, 50, 1.08, 1.08, 1],
['4/1/21', 'a', '1', 'mn', '567', 0.54, 50, 1.08, 1.08, 2],
['4/1/21', 'a', '1', 'mn', '567', 0.54, 50, 1.08, 1.08, 4],
['4/1/21', 'a', '1', 'mn', '567', 0.54, 50, 1.08, 1.08, 2],
['4/1/21', 'a', '1', 'mn', '567', 0.54, 50, 1.08, 1.08, 2],
['4/1/21', 'a', '1', 'mn', '567', 0.54, 50, 1.08, 1.08, 2],
['4/1/21', 'a', '1', 'mn', '567', 0.54, 50, 1.08, 1.08, 2],
['4/1/21', 'a', '1', 'mn', '567', 0.54, 50, 1.08, 1.08, 2],
['4/1/21', 'a', '1', 'mn', '567', 0.54, 50, 1.08, 1.08, 3],
['4/1/21', 'a', '1', 'mn', '567', 0.54, 50, 1.08, 1.08, 4],
['4/1/21', 'a', '1', 'mn', '567', 0.54, 50, 1.08, 1.08, 1],
['3/1/21', 'b', '2', 'mn', '555', 1.3, 50, 2.6, 2.6, 1],
['6/1/21', 'b', '2', 'mn', '555', 1.3, 50, 2.6, 2.6, 1],
['6/1/21', 'b', '2', 'mn', '555', 1.3, 50, 2.6, 2.6, 1],
['6/1/21', 'b', '2', 'mn', '555', 1.3, 50, 2.6, 2.6, 1],
['6/1/21', 'b', '2', 'mn', '555', 1.3, 50, 2.6, 2.6, 1],
]
pdf = pd.DataFrame(data, columns=columns)
pdf = pdf.replace({np.nan: None})
return spark_session.createDataFrame(pdf)
#pytest.fixture
def output_df(spark_session):
data = [
['4/1/21', 'a', '1', 'mn', '567', 0.54, 50, 1.08, 27, 14.580000000000002],
['3/1/21', 'b', '2', 'mn', '555', 1.3, 50, 2.6, 1, 1.3],
]
pdf = pd.DataFrame(data, columns=columns)
pdf = pdf.replace({np.nan: None})
return spark_session.createDataFrame(pdf)
# ======= FIRST RUN CASE
def test_normal_input(input_df, output_df):
calc_output_df = calc(input_df)
assert sorted(calc_output_df.collect()) == sorted(output_df.collect())
#
# Folder Structure
#
# transforms-python/
# ├── ...
# └── src/
# ├── ...
# ├── myproject/
# │ ├── ...
# │ └── analysis/
# │ ├── ...
# │ └── simple_discounts.py
# └── tests/
# ├── ...
# └── unit_tests.py

Response 400 while using Requests package in Django

I want to scrape Myntra using Django Framework but when I put my code in Django project I get 400 error. The same code runs without error when I run it on the same file even in Django. Means calling the MyntraScraperClass in MyntraScraper.py file.
Here is my project directory
BackendController
-MyntraScraper.py
myDjangoApp
-views.py
Inside views.py, there is a function where I am calling my MyntraScraperClass
def tst(request):
------------
The same code that is MyntraScraperClass runs error free when I call it on
BackendController
-MyntraScraper.py
Here is my code:
import requests, json
from bs4 import BeautifulSoup
import os, ssl
import certifi
import urllib3
class MyntraScraperClass:
def __init__(self,url):
self.url=url
def myntra(self):
mt={}
http = urllib3.PoolManager(
cert_reqs='CERT_REQUIRED',
ca_certs=certifi.where())
if (not os.environ.get('PYTHONHTTPSVERIFY', '') and getattr(ssl, '_create_unverified_context', None)):
ssl._create_default_https_context = ssl._create_unverified_context
proxy = {'http': '-------'}
headers = {'User-Agent' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36'}
for x in range(0,5):
print(x)
try:
s = requests.Session()
res = s.get(self.url, headers=headers, verify=True, proxies=proxy)
print(res)
soup = BeautifulSoup(res.text, "lxml")
print(soup)
if "Access Denied" in soup.title:
continue
break
except requests.exceptions.ProxyError:
continue
except Exception as e:
print(e)
mt['error']=e
script = None
for s in soup.find_all("script"):
if 'pdpData' in s.text:
script = s.get_text(strip=True)
break
else:
continue
mt['data'] =json.loads(script[script.index('{'):])
return mt
I am calling MyntraScraperClass in my Django Views from BackendController directory.
def tst(request):
url = request.GET.get('url')
from BackendController.MyntraScraper import MyntraScraperClass
obj1 = MyntraScraperClass(url)
kk = obj1.myntra()
print(kk)
return JsonResponse(kk)
The response is
<Response [400]>
I am getting this in soup
<html><head>
<title>Invalid URL</title>
</head><body>
<h1>Invalid URL</h1>
The requested URL "[no URL]", is invalid.<p>
Reference #9.6b722c31.1596891375.7bfc4ae
</p></body></html>
You should try to solve your problem using https://scrapy.org/, here are the docs https://docs.scrapy.org/en/latest/
import requests, json
from bs4 import BeautifulSoup
headers = {'User-Agent' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36'}
class MyntraScraperClass:
def __init__(self,url):
self.url=url
self.session = requests.Session()
def myntra(self):
res = self.session.get(self.url, headers=headers)
soup = BeautifulSoup(res.text,"lxml")
script = None
for s in soup.find_all("script"):
if 'pdpData' in s.text:
script = s.get_text(strip=True)
break
try:
return json.loads(script[script.index('{'):])
except:
return None
scraperClass = MyntraScraperClass("https://www.myntra.com/sports-shoes/puma/puma-men-blue-hybrid-fuego-running-shoes/11203218/buy")
data = scraperClass.myntra()
print(data)
Output:
{'pdpData': {'id': 11203218, 'name': 'Puma Men Blue Hybrid Fuego Running Shoes', 'mrp': 6499, 'manufacturer': 'SSIPL RETAIL LIMITED, KUNDLI,75, SERSA ROAD, 131028 SONEPAT', 'countryOfOrigin': 'India', 'colours': None, 'baseColour': 'Blue', 'brand': {'uidx': '', 'name': 'Puma', 'image': '', 'bio': ''}, 'media': {'videos': [], 'albums': [{'name': 'default', 'images': [{'src': 'http://assets.myntassets.com/h_($height),q_($qualityPercentage),w_($width)/v1/assets/images/productimage/2019/12/20/0c15e03c-863b-4a4a-9bb7-709a733fd4821576816965952-1.jpg', 'secureSrc': 'https://assets.myntassets.com/h_($height),q_($qualityPercentage),w_($width)/v1/assets/images/productimage/2019/12/20/0c15e03c-863b-4a4a-9bb7-709a733fd4821576816965952-1.jpg', 'host': None, 'imageURL': 'http://assets.myntassets.com/assets/images/productimage/2019/12/20/0c15e03c-863b-4a4a-9bb7-709a733fd4821576816965952-1.jpg', 'annotation': []}, {'src': 'http://assets.myntassets.com/h_($height),q_($qualityPercentage),w_($width)/v1/assets/images/productimage/2019/12/20/69bfa4e0-1ac4-4adf-b84e-4815ff60e8831576816966007-2.jpg', 'secureSrc': 'https://assets.myntassets.com/h_($height),q_($qualityPercentage),w_($width)/v1/assets/images/productimage/2019/12/20/69bfa4e0-1ac4-4adf-b84e-4815ff60e8831576816966007-2.jpg', 'host': None, 'imageURL': 'http://assets.myntassets.com/assets/images/productimage/2019/12/20/69bfa4e0-1ac4-4adf-b84e-4815ff60e8831576816966007-2.jpg', 'annotation': []}, {'src': 'http://assets.myntassets.com/h_($height),q_($qualityPercentage),w_($width)/v1/assets/images/productimage/2019/12/20/d2fd0ca0-1643-43ae-a0fc-fb1309580e151576816966049-3.jpg', 'secureSrc': 'https://assets.myntassets.com/h_($height),q_($qualityPercentage),w_($width)/v1/assets/images/productimage/2019/12/20/d2fd0ca0-1643-43ae-a0fc-fb1309580e151576816966049-3.jpg', 'host': None, 'imageURL': 'http://assets.myntassets.com/assets/images/productimage/2019/12/20/d2fd0ca0-1643-43ae-a0fc-fb1309580e151576816966049-3.jpg', 'annotation': []}, {'src': 'http://assets.myntassets.com/h_($height),q_($qualityPercentage),w_($width)/v1/assets/images/productimage/2019/12/20/0edae428-b9c0-4755-9127-0961d872b78a1576816966095-4.jpg', 'secureSrc': 'https://assets.myntassets.com/h_($height),q_($qualityPercentage),w_($width)/v1/assets/images/productimage/2019/12/20/0edae428-b9c0-4755-9127-0961d872b78a1576816966095-4.jpg', 'host': None, 'imageURL': 'http://assets.myntassets.com/assets/images/productimage/2019/12/20/0edae428-b9c0-4755-9127-0961d872b78a1576816966095-4.jpg', 'annotation': []}, {'src': 'http://assets.myntassets.com/h_($height),q_($qualityPercentage),w_($width)/v1/assets/images/productimage/2019/12/20/c59c7677-2bbd-4dbe-9b02-7c321c29cb701576816966142-5.jpg', 'secureSrc': 'https://assets.myntassets.com/h_($height),q_($qualityPercentage),w_($width)/v1/assets/images/productimage/2019/12/20/c59c7677-2bbd-4dbe-9b02-7c321c29cb701576816966142-5.jpg', 'host': None, 'imageURL': 'http://assets.myntassets.com/assets/images/productimage/2019/12/20/c59c7677-2bbd-4dbe-9b02-7c321c29cb701576816966142-5.jpg', 'annotation': []}]}, {'name': 'animatedImage', 'images': []}]}, 'sbpEnabled': False, 'sizechart': {'sizeChartUrl': None, 'sizeRepresentationUrl': 'http://assets.myntassets.com/assets/images/sizechart/2016/12/12/11481538267795-footwear.png'}, 'sizeRecoLazy': {'actionType': 'lazy', 'action': '/product/11203218/size/recommendation', 'sizeProfileAction': '/user/size-profiles?gender=male&articleType=Sports%20Shoes'}, 'analytics': {'articleType': 'Sports Shoes', 'subCategory': 'Shoes', 'masterCategory': 'Footwear', 'gender': 'Men', 'brand': 'Puma', 'colourHexCode': None}, 'crossLinks': [{'title': 'More Sports Shoes by Puma', 'url': 'sports-shoes?f=Brand:Puma::Gender:men'}, {'title': 'More Blue Sports Shoes', 'url': 'sports-shoes?f=Color:Blue_0074D9::Gender:men'}, {'title': 'More Sports Shoes', 'url': 'sports-shoes?f=Gender:men'}], 'relatedStyles': None, 'disclaimerTitle': '', 'productDetails': [{'type': None, 'content': None, 'title': 'Product Details', 'description': "<b>FEATURES + BENEFITS</b><br>HYBRID: PUMA's combination of two of its best technologies: IGNITE foam and NRGY beads<br>IGNITE: PUMA's foam midsole and branded heel cage supports and stabilises by locking the heel onto the platform<br>NRGY: PUMA's foam midsole offers superior cushion from heel to toe so you can power through your run<br>Heel-to-toe drop: 12mm<br><br><b>Product Design Details</b><ul><li>A pair of blue & brown running sports shoes, has regular styling, lace-up detail</li><li>Low boot silhouette</li><li>Lightweight synthetic upper</li><li>Overlays to secure the heel</li><li>Classic tongue</li><li>Lace-up closure</li><li>Rubber outsole for traction and durability</li><li>PUMA Wordmark at the tongue</li><li>PUMA Cat Logo at heel</li><li>Warranty: 3 months</li><li>Warranty provided by brand/manufacturer</li></ul><br><b>PRODUCT STORY</b><br>Change the name of the game with the HYBRID Fuego running sneakers. This bold colour-blocked shoe pairs a HYBRID foam midsole and a grippy rubber outsole for the ultimate in comfort and stability while still maintaining a stylish edge."}, {'type': None, 'content': None, 'title': 'MATERIAL & CARE', 'description': 'Textile<br>Wipe with a clean, dry cloth to remove dust'}], 'preOrder': None, 'sizeChartDisclaimerText': '', 'tags': None, 'articleAttributes': {'Ankle Height': 'Regular', 'Arch Type': 'Medium', 'Cleats': 'No Cleats', 'Cushioning': 'Medium', 'Distance': 'Medium', 'Fastening': 'Lace-Ups', 'Material': 'Textile', 'Outsole Type': 'Marking', 'Pronation for Running Shoes': 'Neutral', 'Running Type': 'Road Running', 'Sole Material': 'Rubber', 'Sport': 'Running', 'Surface Type': 'Outdoor', 'Technology': 'NA', 'Warranty': '3 months'}, 'systemAttributes': [], 'ratings': None, 'urgency': [{'value': '0', 'type': 'PURCHASED', 'ptile': 0}, {'value': '0', 'type': 'CART', 'ptile': 0}, {'value': '0', 'type': 'WISHLIST', 'ptile': 0}, {'value': '0', 'type': 'PDP', 'ptile': 0}], 'catalogAttributes': {'catalogDate': '1576751286000', 'season': 'summer', 'year': '2020'}, 'productContentGroupEntries': [{'title': '', 'type': 'DETAILS', 'attributes': [{'attributeName': 'Product Details', 'attributeType': 'STRING', 'value': "<b>FEATURES + BENEFITS</b><br>HYBRID: PUMA's combination of two of its best technologies: IGNITE foam and NRGY beads<br>IGNITE: PUMA's foam midsole and branded heel cage supports and stabilises by locking the heel onto the platform<br>NRGY: PUMA's foam midsole offers superior cushion from heel to toe so you can power through your run<br>Heel-to-toe drop: 12mm<br><br><b>Product Design Details</b><ul><li>A pair of blue & brown running sports shoes, has regular styling, lace-up detail</li><li>Low boot silhouette</li><li>Lightweight synthetic upper</li><li>Overlays to secure the heel</li><li>Classic tongue</li><li>Lace-up closure</li><li>Rubber outsole for traction and durability</li><li>PUMA Wordmark at the tongue</li><li>PUMA Cat Logo at heel</li><li>Warranty: 3 months</li><li>Warranty provided by brand/manufacturer</li></ul><br><b>PRODUCT STORY</b><br>Change the name of the game with the HYBRID Fuego running sneakers. This bold colour-blocked shoe pairs a HYBRID foam midsole and a grippy rubber outsole for the ultimate in comfort and stability while still maintaining a stylish edge."}, {'attributeName': 'Material & Care', 'attributeType': 'STRING', 'value': 'Textile<br>Wipe with a clean, dry cloth to remove dust'}, {'attributeName': 'Style Note', 'attributeType': 'STRING', 'value': "You'll look and feel super stylish in these trendsetting sports shoes by Puma. Match this blue pair with track pants and a sleeveless sports T-shirt when heading out for a casual day with friends."}]}], 'shoppableLooks': None, 'descriptors': [{'title': 'description', 'description': "<b>FEATURES + BENEFITS</b><br>HYBRID: PUMA's combination of two of its best technologies: IGNITE foam and NRGY beads<br>IGNITE: PUMA's foam midsole and branded heel cage supports and stabilises by locking the heel onto the platform<br>NRGY: PUMA's foam midsole offers superior cushion from heel to toe so you can power through your run<br>Heel-to-toe drop: 12mm<br><br><b>Product Design Details</b><ul><li>A pair of blue & brown running sports shoes, has regular styling, lace-up detail</li><li>Low boot silhouette</li><li>Lightweight synthetic upper</li><li>Overlays to secure the heel</li><li>Classic tongue</li><li>Lace-up closure</li><li>Rubber outsole for traction and durability</li><li>PUMA Wordmark at the tongue</li><li>PUMA Cat Logo at heel</li><li>Warranty: 3 months</li><li>Warranty provided by brand/manufacturer</li></ul><br><b>PRODUCT STORY</b><br>Change the name of the game with the HYBRID Fuego running sneakers. This bold colour-blocked shoe pairs a HYBRID foam midsole and a grippy rubber outsole for the ultimate in comfort and stability while still maintaining a stylish edge."}, {'title': 'style_note', 'description': "You'll look and feel super stylish in these trendsetting sports shoes by Puma. Match this blue pair with track pants and a sleeveless sports T-shirt when heading out for a casual day with friends."}, {'title': 'materials_care_desc', 'description': 'Textile<br>Wipe with a clean, dry cloth to remove dust'}], 'flags': {'isExchangeable': True, 'isReturnable': True, 'openBoxPickupEnabled': True, 'tryAndBuyEnabled': True, 'isLarge': False, 'isHazmat': False, 'isFragile': False, 'isJewellery': False, 'outOfStock': False, 'codEnabled': True, 'globalStore': False, 'loyaltyPointsEnabled': False, 'emiEnabled': True, 'chatEnabled': False, 'measurementModeEnabled': False, 'sampleModeEnabled': False, 'disableBuyButton': False}, 'earlyBirdOffer': None, 'serviceability': {'launchDate': '', 'returnPeriod': 30, 'descriptors': ['Pay on delivery might be available', 'Easy 30 days returns and exchanges', 'Try & Buy might be available'], 'procurementTimeInDays': {'6206': 4}}, 'buyButtonSellerOrder': [{'skuId': 38724440, 'sellerPartnerId': 6206}, {'skuId': 38724442, 'sellerPartnerId': 6206}, {'skuId': 38724446, 'sellerPartnerId': 6206}, {'skuId': 38724450, 'sellerPartnerId': 6206}, {'skuId': 38724452, 'sellerPartnerId': 6206}, {'skuId': 38724444, 'sellerPartnerId': 6206}, {'skuId': 38724448, 'sellerPartnerId': 6206}], 'sellers': [{'sellerPartnerId': 6206, 'sellerName': 'Puma Sports India Pvt. Ltd.(NSCM)'}], 'sizes': [{'skuId': 38724440, 'styleId': 11203218, 'action': '/product/11203218/related/6?co=1', 'label': '6', 'available': True, 'sizeType': 'UK Size', 'originalStyle': True, 'measurements': [{'type': 'Body Measurement', 'name': 'To Fit Foot Length', 'value': '24.5', 'minValue': '24.5', 'maxValue': '24.5', 'unit': 'cm', 'displayText': '24.5cm'}], 'allSizesList': [{'scaleCode': 'uk_size', 'sizeValue': '6', 'size': 'UK Size', 'order': 1, 'prefix': 'UK'}, {'scaleCode': 'us_size', 'sizeValue': '7', 'size': 'US Size', 'order': 2, 'prefix': 'US'}, {'scaleCode': 'euro_size', 'sizeValue': '39', 'size': 'Euro Size', 'order': 3, 'prefix': 'EURO'}], 'sizeSellerData': [{'mrp': 6499, 'sellerPartnerId': 6206, 'availableCount': 10, 'sellableInventoryCount': 10, 'warehouses': ['106'], 'supplyType': 'ON_HAND', 'discountId': '11203218:23363948', 'discountedPrice': 2924}]}, {'skuId': 38724442, 'styleId': 11203218, 'action': '/product/11203218/related/7?co=1', 'label': '7', 'available': True, 'sizeType': 'UK Size', 'originalStyle': True, 'measurements': [{'type': 'Body Measurement', 'name': 'To Fit Foot Length', 'value': '25.4', 'minValue': '25.4', 'maxValue': '25.4', 'unit': 'cm', 'displayText': '25.4cm'}], 'allSizesList': [{'scaleCode': 'uk_size', 'sizeValue': '7', 'size': 'UK Size', 'order': 1, 'prefix': 'UK'}, {'scaleCode': 'us_size', 'sizeValue': '8', 'size': 'US Size', 'order': 2, 'prefix': 'US'}, {'scaleCode': 'euro_size', 'sizeValue': '40.5', 'size': 'Euro Size', 'order': 3, 'prefix': 'EURO'}], 'sizeSellerData': [{'mrp': 6499, 'sellerPartnerId': 6206, 'availableCount': 49, 'sellableInventoryCount': 49, 'warehouses': ['106'], 'supplyType': 'ON_HAND', 'discountId': '11203218:23363948', 'discountedPrice': 2924}]}, {'skuId': 38724444, 'styleId': 11203218, 'action': '/product/11203218/related/8?co=1', 'label': '8', 'available': True, 'sizeType': 'UK Size', 'originalStyle': True, 'measurements': [{'type': 'Body Measurement', 'name': 'To Fit Foot Length', 'value': '26.2', 'minValue': '26.2', 'maxValue': '26.2', 'unit': 'cm', 'displayText': '26.2cm'}], 'allSizesList': [{'scaleCode': 'uk_size', 'sizeValue': '8', 'size': 'UK Size', 'order': 1, 'prefix': 'UK'}, {'scaleCode': 'us_size', 'sizeValue': '9', 'size': 'US Size', 'order': 2, 'prefix': 'US'}, {'scaleCode': 'euro_size', 'sizeValue': '42', 'size': 'Euro Size', 'order': 3, 'prefix': 'EURO'}], 'sizeSellerData': [{'mrp': 6499, 'sellerPartnerId': 6206, 'availableCount': 121, 'sellableInventoryCount': 121, 'warehouses': ['106'], 'supplyType': 'ON_HAND', 'discountId': '11203218:23363948', 'discountedPrice': 2924}]}, {'skuId': 38724446, 'styleId': 11203218, 'action': '/product/11203218/related/9?co=1', 'label': '9', 'available': True, 'sizeType': 'UK Size', 'originalStyle': True, 'measurements': [{'type': 'Body Measurement', 'name': 'To Fit Foot Length', 'value': '27.1', 'minValue': '27.1', 'maxValue': '27.1', 'unit': 'cm', 'displayText': '27.1cm'}], 'allSizesList': [{'scaleCode': 'uk_size', 'sizeValue': '9', 'size': 'UK Size', 'order': 1, 'prefix': 'UK'}, {'scaleCode': 'us_size', 'sizeValue': '10', 'size': 'US Size', 'order': 2, 'prefix': 'US'}, {'scaleCode': 'euro_size', 'sizeValue': '43', 'size': 'Euro Size', 'order': 3, 'prefix': 'EURO'}], 'sizeSellerData': [{'mrp': 6499, 'sellerPartnerId': 6206, 'availableCount': 107, 'sellableInventoryCount': 107, 'warehouses': ['106'], 'supplyType': 'ON_HAND', 'discountId': '11203218:23363948', 'discountedPrice': 2924}]}, {'skuId': 38724448, 'styleId': 11203218, 'action': '/product/11203218/related/10?co=1', 'label': '10', 'available': True, 'sizeType': 'UK Size', 'originalStyle': True, 'measurements': [{'type': 'Body Measurement', 'name': 'To Fit Foot Length', 'value': '27.9', 'minValue': '27.9', 'maxValue': '27.9', 'unit': 'cm', 'displayText': '27.9cm'}], 'allSizesList': [{'scaleCode': 'uk_size', 'sizeValue': '10', 'size': 'UK Size', 'order': 1, 'prefix': 'UK'}, {'scaleCode': 'us_size', 'sizeValue': '11', 'size': 'US Size', 'order': 2, 'prefix': 'US'}, {'scaleCode': 'euro_size', 'sizeValue': '44.5', 'size': 'Euro Size', 'order': 3, 'prefix': 'EURO'}], 'sizeSellerData': [{'mrp': 6499, 'sellerPartnerId': 6206, 'availableCount': 112, 'sellableInventoryCount': 112, 'warehouses': ['106'], 'supplyType': 'ON_HAND', 'discountId': '11203218:23363948', 'discountedPrice': 2924}]}, {'skuId': 38724450, 'styleId': 11203218, 'action': '/product/11203218/related/11?co=1', 'label': '11', 'available': True, 'sizeType': 'UK Size', 'originalStyle': True, 'measurements': [{'type': 'Body Measurement', 'name': 'To Fit Foot Length', 'value': '28.8', 'minValue': '28.8', 'maxValue': '28.8', 'unit': 'cm', 'displayText': '28.8cm'}], 'allSizesList': [{'scaleCode': 'uk_size', 'sizeValue': '11', 'size': 'UK Size', 'order': 1, 'prefix': 'UK'}, {'scaleCode': 'us_size', 'sizeValue': '12', 'size': 'US Size', 'order': 2, 'prefix': 'US'}, {'scaleCode': 'euro_size', 'sizeValue': '46', 'size': 'Euro Size', 'order': 3, 'prefix': 'EURO'}], 'sizeSellerData': [{'mrp': 6499, 'sellerPartnerId': 6206, 'availableCount': 18, 'sellableInventoryCount': 18, 'warehouses': ['106'], 'supplyType': 'ON_HAND', 'discountId': '11203218:23363948', 'discountedPrice': 2924}]}, {'skuId': 38724452, 'styleId': 11203218, 'action': '/product/11203218/related/12?co=1', 'label': '12', 'available': False, 'sizeType': 'UK Size', 'originalStyle': True, 'measurements': [{'type': 'Body Measurement', 'name': 'To Fit Foot Length', 'value': '29.6', 'minValue': '29.6', 'maxValue': '29.6', 'unit': 'cm', 'displayText': '29.6cm'}], 'allSizesList': [{'scaleCode': 'uk_size', 'sizeValue': '12', 'size': 'UK Size', 'order': 1, 'prefix': 'UK'}, {'scaleCode': 'us_size', 'sizeValue': '13', 'size': 'US Size', 'order': 2, 'prefix': 'US'}, {'scaleCode': 'euro_size', 'sizeValue': '47', 'size': 'Euro Size', 'order': 3, 'prefix': 'EURO'}], 'sizeSellerData': []}], 'discounts': [{'type': 1, 'freeItem': False, 'label': '(55% OFF)', 'discountText': '', 'timerStart': '0', 'timerEnd': '1597084200', 'discountPercent': 55, 'offer': '', 'discountId': '11203218:23363948', 'heading': None, 'description': None, 'link': None, 'freeItemImage': None}], 'offers': [{'type': 'EMI', 'title': 'EMI option available', 'description': '', 'action': '/faqs', 'image': None}], 'bundledSkus': None, 'richPdp': None, 'landingPageUrl': 'sports-shoes/puma/puma-men-blue-hybrid-fuego-running-shoes/11203218/buy'}, 'pageName': 'Pdp', 'atsa': ['Sport', 'Material', 'Fastening', 'Ankle Height', 'Outsole Type', 'Cleats', 'Pronation for Running Shoes', 'Arch Type', 'Cushioning', 'Running Type', 'Warranty', 'Distance', 'Number of Components', 'Surface Type', 'Technology']}

How to plot multiple value for one X-axis chart.js

I have implemented Charts JS library in one of my web apps and am having an issue. Right now i need to add multiple y values to one single x-axis point. however did not come to solution.
var ctx = document.getElementById("myChart").getContext("2d");
new Chart(ctx, config);
var config = {
type: 'line',
data: {
labels: [['01', '11' ,'2018'],
['01', '11' ,'2018'],
['01', '11' ,'2018'],
['01','11','2018'], '02','02','02','02','02','05','05','05','05','06','06','06','06','07','07','07','07','07','07','07','07','08','08','08','08','08','08','08','08','09','09','09','09',['20','02','2019'],['20','02','2019'],'21','21','21','21',['06','03'],['06','03'] ,'','','','' ,
],
datasets: [{
label: "My First dataset",
data: [35.48 ,35.50 ,35.5 ,35.49 ,35.49 ,35.50 ,35.50 ,35.49 ,35.45 ,35.38 ,35.42 ,35.4 ,35.49 ,35.50 ,35.49 ,35.49 ,35.49 ,35.49 ,35.50 ,35.50 ,35.48 ,35.47 ,35.48 ,35.47 ,35.49 ,35.50 ,35.50 ,35.49 ,35.48 ,35.47 ,35.48 ,35.47 ,35.50 ,35.49 ,35.49 ,35.50 ,37 ,37 ,38 ,39 ,40 ,51 ,28 ,29 ],
}]
},
options: {
scales: {
xAxes:[{
ticks: {
autoSkip: false,
}
}],
},
}
};
var ctx = document.getElementById("myChart").getContext("2d");
new Chart(ctx, config);
<canvas id="myChart"></canvas>
You can add multiple datasets which will plot a separate line on the graph.
Here is your example.
function newDate() {
return moment().add(days, 'd');
}
var config = {
type: 'line',
data: {
labels: [
["01", "11", "2018"],
['01', '11', '2018'],
['01', '11', '2018'],
['01', '11', '2018'], , '02', '02', '02', '02', '05', '05', '05', '05', '06', '06', '06', '06', '07', '07', '07', '07', '07', '07', '07', '07', '08', '08', '08', '08', '08', '08', '08', '08', '09', '09', '09', '09', ['20', '02', '2019'],
['20', '02', '2019'], '21', '21', '21', '21', ['06', '03'],
['06', '03'], '', '', '', '', '', '', '', '', '', '', '', '', '', ''
],
datasets: [{
label: "My First dataset",
data: [35.48, 35.50, 35.5, 35.49, 35.49, 35.50, 35.50, 35.49, 35.45, 35.38, 35.42, 35.4, 35.49, 35.50, 35.49, 35.49, 35.49, 35.49, 35.50, 35.50, 35.48, 35.47, 35.48, 35.47, 35.49, 35.50, 35.50, 35.49, 35.48, 35.47, 35.48, 35.47, 35.50, 35.49, 35.49, 35.50, 37, 37, 38, 39, 40, 51, 28, 29],
},
{
label: "My second dataset",
data: [35.48, 35.50, 35.5, 35.49, 35.49, 35.50, 35.50, 35.49, 35.45, 35.38, 35.42, 35.4, 35.49, 35.50, 35.49, 35.49, 35.49, 35.49, 35.50, 35.50, 35.48, 35.47, 35.48, 35.47, 35.49, 35.50, 35.50, 35.49, 35.48, 35.47, 35.48, 35.47, 35.50, 35.49, 35.49, 35.50, 37, 37, 38, 39, 40, 51, 28, 29].map(a => a + 20),
}
]
},
options: {
scales: {
xAxes: [{
ticks: {
autoSkip: false
}
}],
},
}
};
var ctx = document.getElementById("myChart").getContext("2d");
new Chart(ctx, config);
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.0/Chart.bundle.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/moment.min.js"></script>
<canvas id="myChart"></canvas>

google bar chart color for negative values or values less than 0

I am looking for an option to make the color of google bar chart as 'RED' when values are less than 0. For now I have tried many things. But none work.
I have also checked colorFormater and the function colorNegative but that works only with the Table and not with coreChart. Below is the code I am using. Please suggest.
google.charts.load('current', {'packages':['corechart','bar']});
google.charts.setOnLoadCallback(drawBasic);
function drawBasic() {
var data = new google.visualization.arrayToDataTable([
['', 'Cost'],
['A', 20],
['B', 30 ],
['C', 50 ],
['D', 60],
['E', 90 ],
['F', 24 ],
['G', 40 ],
['H', 0],
['I', 0],
['J', -30 ],
['K', -54 ],
['L', -60]
]);
var options = {
width: 419,
colors: ['#bac405','#f95602'],
bars: 'horizontal',
legend:'bottom',
};
var chart = new google.visualization.BarChart(document.getElementById('function'));
chart.draw(data,options);
}
I have got the answer for my question. Just added view to the bars.
Thanks to this link - http://jsfiddle.net/asgallant/QHJA6/
google.charts.load('current', {'packages':['corechart','bar']});
google.charts.setOnLoadCallback(drawBasic);
function drawBasic() {
var data = new google.visualization.arrayToDataTable([
['', 'Cost'],
['A', 20],
['B', 30 ],
['C', 50 ],
['D', 60],
['E', 90 ],
['F', 24 ],
['G', 40 ],
['H', 0],
['I', 0],
['J', -30 ],
['K', -54 ],
['L', -60]
]);
var view = new google.visualization.DataView(data);
view.setColumns([0, {
type: 'number',
label: 'Value',
calc: function (dt, row) {
return (dt.getValue(row, 1) < 0) ? dt.getValue(row, 1) : null;
}
}, {
type: 'number',
label: 'Value',
calc: function (dt, row) {
return (dt.getValue(row, 1) > 0) ? dt.getValue(row, 1) : null;
}
}]);
var options = {
width: 419,
colors: ['red','#bac405'],
bars: 'horizontal',
legend:'none',
isStacked: true
};
var chart = new google.visualization.BarChart(document.getElementById('function'));
chart.draw(view,options);
}

Formatting Python Output

I am trying to get server information and add it to dictionary for later to be able to create a web page that contains this information.
How would you format this? Would you add it to dictionary or keep it as a list?
Command: >>> hpilo.Ilo.get_embedded_health(server_conn):
Outout:
{'fans': {'Fan 2': {'status': 'OK', 'speed': (13, 'Percentage'), 'zone': 'System', 'label': 'Fan 2'}, 'Fan 3': {'status': 'OK', 'speed': (6, 'Percentage'), 'zone': 'System', 'label': 'Fan 3'}, 'Fan 1': {'status': 'OK', 'speed': (6, 'Percentage'), 'zone': 'System', 'label': 'Fan 1'}, 'Fan 6': {'status': 'OK', 'speed': (43, 'Percentage'), 'zone': 'System', 'label': 'Fan 6'}, 'Fan 4': {'status': 'OK', 'speed': (34, 'Percentage'), 'zone': 'System', 'label': 'Fan 4'}, 'Fan 5': {'status': 'OK', 'speed': (43, 'Percentage'), 'zone': 'System', 'label': 'Fan 5'}}, 'health_at_a_glance': {'temperature': {'status': 'OK'}, 'storage': {'status': 'OK'}, 'fans': {'status': 'OK', 'redundancy': 'Redundant'}, 'bios_hardware': {'status': 'OK'}, 'memory': {'status': 'OK'}, 'power_supplies': {'status': 'OK', 'redundancy': 'Redundant'}, 'processor': {'status': 'OK'}, 'network': {'status': 'OK'}}, 'temperature': {'05-P1 DIMM 4-6': {'status': 'OK', 'currentreading': (21, 'Celsius'), 'label': '05-P1 DIMM 4-6', 'critical': 'N/A', 'caution': (87, 'Celsius'), 'location': 'Memory'}, '12-HD Max': {'status': 'OK', 'currentreading': (35, 'Celsius'), 'label': '12-HD Max', 'critical': 'N/A', 'caution': (60, 'Celsius'), 'location': 'System'}, '10-P2 DIMM 7-9': {'status': 'OK', 'currentreading': (21, 'Celsius'), 'label': '10-P2 DIMM 7-9', 'critical': 'N/A', 'caution': (87, 'Celsius'), 'location': 'Memory'}, '20-VR P1 Mem': {'status': 'OK', 'currentreading': (27, 'Celsius'), 'label': '20-VR P1 Mem', 'critical': (120, 'Celsius'), 'caution': (115, 'Celsius'), 'location': 'Power Supply'}, '32-PCI 5': {'status': 'Not Installed', 'currentreading': 'N/A', 'label': '32-PCI 5', 'critical': 'N/A', 'caution': 'N/A', 'location': 'I/O Board'}, '27-LOM Card': {'status': 'Not Installed', 'currentreading': 'N/A', 'label': '27-LOM Card', 'critical': 'N/A', 'caution': 'N/A', 'location': 'I/O Board'}, '38-PCI 5 Zone': {'status': 'Not Installed', 'currentreading': 'N/A', 'label': '38-PCI 5 Zone', 'critical': 'N/A', 'caution': 'N/A', 'location': 'I/O Board'}, '14-P/S 1': {'status': 'OK', 'currentreading': (21, 'Celsius'), 'label': '14-P/S 1', 'critical': 'N/A', 'caution': 'N/A', 'location': 'Power Supply'}, '17-VR P1': {'status': 'OK', 'currentreading': (26, 'Celsius'), 'label': '17-VR P1', 'critical': (120, 'Celsius'), 'caution': (115, 'Celsius'), 'location': 'Power Supply'}, '45-SuperCap Max': {'status': 'OK', 'currentreading': (19, 'Celsius'), 'label': '45-SuperCap Max', 'critical': 'N/A', 'caution': (65, 'Celsius'), 'location': 'System'}, '19-VR P1 Mem': {'status': 'OK', 'currentreading': (31, 'Celsius'), 'label': '19-VR P1 Mem', 'critical': (120, 'Celsius'), 'caution': (115, 'Celsius'), 'location': 'Power Supply'}, '30-PCI 3': {'status': 'Not Installed', 'currentreading': 'N/A', 'label': '30-PCI 3', 'critical': 'N/A', 'caution': 'N/A', 'location': 'I/O Board'}, '07-P1 DIMM 10-12': {'status': 'OK', 'currentreading': (20, 'Celsius'), 'label': '07-P1 DIMM 10-12', 'critical': 'N/A', 'caution': (87, 'Celsius'), 'location': 'Memory'}, '44-System Board': {'status': 'OK', 'currentreading': (23, 'Celsius'), 'label': '44-System Board', 'critical': (85, 'Celsius'), 'caution': (80, 'Celsius'), 'location': 'System'}, '24-VR P2Vtt Zone': {'status': 'OK', 'currentreading': (26, 'Celsius'), 'label': '24-VR P2Vtt Zone', 'critical': (95, 'Celsius'), 'caution': (90, 'Celsius'), 'location': 'Power Supply'}, '01-Inlet Ambient': {'status': 'OK', 'currentreading': (17, 'Celsius'), 'label': '01-Inlet Ambient', 'critical': (46, 'Celsius'), 'caution': (42, 'Celsius'), 'location': 'Ambient'}, '31-PCI 4': {'status': 'Not Installed', 'currentreading': 'N/A', 'label': '31-PCI 4', 'critical': 'N/A', 'caution': 'N/A', 'location': 'I/O Board'}, '03-CPU 2': {'status': 'OK', 'currentreading': (40, 'Celsius'), 'label': '03-CPU 2', 'critical': 'N/A', 'caution': (70, 'Celsius'), 'location': 'CPU'}, '43-BIOS Zone': {'status': 'OK', 'currentreading': (30, 'Celsius'), 'label': '43-BIOS Zone', 'critical': (95, 'Celsius'), 'caution': (90, 'Celsius'), 'location': 'System Board'}, '29-PCI 2': {'status': 'Not Installed', 'currentreading': 'N/A', 'label': '29-PCI 2', 'critical': 'N/A', 'caution': 'N/A', 'location': 'I/O Board'}, '34-PCI 1 Zone': {'status': 'OK', 'currentreading': (21, 'Celsius'), 'label': '34-PCI 1 Zone', 'critical': (70, 'Celsius'), 'caution': (65, 'Celsius'), 'location': 'I/O Board'}, '47-Battery Zone': {'status': 'OK', 'currentreading': (25, 'Celsius'), 'label': '47-Battery Zone', 'critical': (80, 'Celsius'), 'caution': (75, 'Celsius'), 'location': 'System'}, '21-VR P2 Mem': {'status': 'OK', 'currentreading': (30, 'Celsius'), 'label': '21-VR P2 Mem', 'critical': (120, 'Celsius'), 'caution': (115, 'Celsius'), 'location': 'Power Supply'}, '13-Chipset': {'status': 'OK', 'currentreading': (44, 'Celsius'), 'label': '13-Chipset', 'critical': 'N/A', 'caution': (105, 'Celsius'), 'location': 'System'}, '02-CPU 1': {'status': 'OK', 'currentreading': (40, 'Celsius'), 'label': '02-CPU 1', 'critical': 'N/A', 'caution': (70, 'Celsius'), 'location': 'CPU'}, '42-VR P1 Zone': {'status': 'OK', 'currentreading': (20, 'Celsius'), 'label': '42-VR P1 Zone', 'critical': (100, 'Celsius'), 'caution': (95, 'Celsius'), 'location': 'Power Supply'}, '23-VR P1Vtt Zone': {'status': 'OK', 'currentreading': (24, 'Celsius'), 'label': '23-VR P1Vtt Zone', 'critical': (95, 'Celsius'), 'caution': (90, 'Celsius'), 'location': 'Power Supply'}, '37-PCI 4 Zone': {'status': 'Not Installed', 'currentreading': 'N/A', 'label': '37-PCI 4 Zone', 'critical': 'N/A', 'caution': 'N/A', 'location': 'I/O Board'}, '09-P2 DIMM 4-6': {'status': 'OK', 'currentreading': (28, 'Celsius'), 'label': '09-P2 DIMM 4-6', 'critical': 'N/A', 'caution': (87, 'Celsius'), 'location': 'Memory'}, '22-VR P2 Mem': {'status': 'OK', 'currentreading': (32, 'Celsius'), 'label': '22-VR P2 Mem', 'critical': (120, 'Celsius'), 'caution': (115, 'Celsius'), 'location': 'Power Supply'}, '26-iLO Zone': {'status': 'OK', 'currentreading': (26, 'Celsius'), 'label': '26-iLO Zone', 'critical': (95, 'Celsius'), 'caution': (90, 'Celsius'), 'location': 'System'}, '50-Sys Exhaust': {'status': 'OK', 'currentreading': (26, 'Celsius'), 'label': '50-Sys Exhaust', 'critical': (80, 'Celsius'), 'caution': (75, 'Celsius'), 'location': 'Chassis'}, '41-I/O Board 2': {'status': 'Not Installed', 'currentreading': 'N/A', 'label': '41-I/O Board 2', 'critical': 'N/A', 'caution': 'N/A', 'location': 'I/O Board'}, '48-I/O Zone': {'status': 'OK', 'currentreading': (27, 'Celsius'), 'label': '48-I/O Zone', 'critical': (80, 'Celsius'), 'caution': (75, 'Celsius'), 'location': 'System'}, '46-Chipset Zone': {'status': 'OK', 'currentreading': (26, 'Celsius'), 'label': '46-Chipset Zone', 'critical': (80, 'Celsius'), 'caution': (75, 'Celsius'), 'location': 'System'}, '04-P1 DIMM 1-3': {'status': 'OK', 'currentreading': (21, 'Celsius'), 'label': '04-P1 DIMM 1-3', 'critical': 'N/A', 'caution': (87, 'Celsius'), 'location': 'Memory'}, '06-P1 DIMM 7-9': {'status': 'OK', 'currentreading': (20, 'Celsius'), 'label': '06-P1 DIMM 7-9', 'critical': 'N/A', 'caution': (87, 'Celsius'), 'location': 'Memory'}, '39-PCI 6 Zone': {'status': 'Not Installed', 'currentreading': 'N/A', 'label': '39-PCI 6 Zone', 'critical': 'N/A', 'caution': 'N/A', 'location': 'I/O Board'}, '16-P/S 2 Zone': {'status': 'OK', 'currentreading': (24, 'Celsius'), 'label': '16-P/S 2 Zone', 'critical': (80, 'Celsius'), 'caution': (75, 'Celsius'), 'location': 'Power Supply'}, '18-VR P2': {'status': 'OK', 'currentreading': (30, 'Celsius'), 'label': '18-VR P2', 'critical': (120, 'Celsius'), 'caution': (115, 'Celsius'), 'location': 'Power Supply'}, '35-PCI 2 Zone': {'status': 'OK', 'currentreading': (23, 'Celsius'), 'label': '35-PCI 2 Zone', 'critical': (71, 'Celsius'), 'caution': (66, 'Celsius'), 'location': 'I/O Board'}, '08-P2 DIMM 1-3': {'status': 'OK', 'currentreading': (26, 'Celsius'), 'label': '08-P2 DIMM 1-3', 'critical': 'N/A', 'caution': (87, 'Celsius'), 'location': 'Memory'}, '40-I/O Board 1': {'status': 'OK', 'currentreading': (25, 'Celsius'), 'label': '40-I/O Board 1', 'critical': (71, 'Celsius'), 'caution': (66, 'Celsius'), 'location': 'I/O Board'}, '28-PCI 1': {'status': 'Not Installed', 'currentreading': 'N/A', 'label': '28-PCI 1', 'critical': 'N/A', 'caution': 'N/A', 'location': 'I/O Board'}, '49-Sys Exhaust': {'status': 'OK', 'currentreading': (26, 'Celsius'), 'label': '49-Sys Exhaust', 'critical': (80, 'Celsius'), 'caution': (75, 'Celsius'), 'location': 'Chassis'}, '25-HD Controller': {'status': 'OK', 'currentreading': (48, 'Celsius'), 'label': '25-HD Controller', 'critical': 'N/A', 'caution': (100, 'Celsius'), 'location': 'System'}, '36-PCI 3 Zone': {'status': 'OK', 'currentreading': (23, 'Celsius'), 'label': '36-PCI 3 Zone', 'critical': (71, 'Celsius'), 'caution': (66, 'Celsius'), 'location': 'I/O Board'}, '33-PCI 6': {'status': 'Not Installed', 'currentreading': 'N/A', 'label': '33-PCI 6', 'critical': 'N/A', 'caution': 'N/A', 'location': 'I/O Board'}, '15-P/S 2': {'status': 'OK', 'currentreading': (23, 'Celsius'), 'label': '15-P/S 2', 'critical': 'N/A', 'caution': 'N/A', 'location': 'Power Supply'}, '11-P2 DIMM 10-12': {'status': 'OK', 'currentreading': (21, 'Celsius'), 'label': '11-P2 DIMM 10-12', 'critical': 'N/A', 'caution': (87, 'Celsius'), 'location': 'Memory'}}, 'memory': {'memory_details': {'CPU_2': {'socket 3': {'status': 'Good, In Use', 'socket': 3, 'ranks': 2, 'technology': 'RDIMM', 'frequency': '1333 MHz', 'minimum_voltage': '1.35 v', 'hp_smart_memory': 'Yes', 'type': 'DIMM DDR3', 'size': '16384 MB'}, 'socket 2': {'status': 'Good, In Use', 'socket': 2, 'ranks': 2, 'technology': 'RDIMM', 'frequency': '1333 MHz', 'minimum_voltage': '1.35 v', 'hp_smart_memory': 'Yes', 'type': 'DIMM DDR3', 'size': '16384 MB'}, 'socket 1': {'status': 'Good, In Use', 'socket': 1, 'ranks': 2, 'technology': 'RDIMM', 'frequency': '1333 MHz', 'minimum_voltage': '1.35 v', 'hp_smart_memory': 'Yes', 'type': 'DIMM DDR3', 'size': '16384 MB'}, 'socket 7': {'status': 'Good, In Use', 'socket': 7, 'ranks': 2, 'technology': 'RDIMM', 'frequency': '1333 MHz', 'minimum_voltage': '1.35 v', 'hp_smart_memory': 'Yes', 'type': 'DIMM DDR3', 'size': '16384 MB'}, 'socket 6': {'status': 'Good, In Use', 'socket': 6, 'ranks': 2, 'technology': 'RDIMM', 'frequency': '1333 MHz', 'minimum_voltage': '1.35 v', 'hp_smart_memory': 'Yes', 'type': 'DIMM DDR3', 'size': '16384 MB'}, 'socket 5': {'status': 'Good, In Use', 'socket': 5, 'ranks': 2, 'technology': 'RDIMM', 'frequency': '1333 MHz', 'minimum_voltage': '1.35 v', 'hp_smart_memory': 'Yes', 'type': 'DIMM DDR3', 'size': '16384 MB'}, 'socket 4': {'status': 'Good, In Use', 'socket': 4, 'ranks': 2, 'technology': 'RDIMM', 'frequency': '1333 MHz', 'minimum_voltage': '1.35 v', 'hp_smart_memory': 'Yes', 'type': 'DIMM DDR3', 'size': '16384 MB'}, 'socket 9': {'status': 'Good, In Use', 'socket': 9, 'ranks': 2, 'technology': 'RDIMM', 'frequency': '1333 MHz', 'minimum_voltage': '1.35 v', 'hp_smart_memory': 'Yes', 'type': 'DIMM DDR3', 'size': '16384 MB'}, 'socket 8': {'status': 'Good, In Use', 'socket': 8, 'ranks': 2, 'technology': 'RDIMM', 'frequency': '1333 MHz', 'minimum_voltage': '1.35 v', 'hp_smart_memory': 'Yes', 'type': 'DIMM DDR3', 'size': '16384 MB'}, 'socket 11': {'status': 'Good, In Use', 'socket': 11, 'ranks': 2, 'technology': 'RDIMM', 'frequency': '1333 MHz', 'minimum_voltage': '1.35 v', 'hp_smart_memory': 'Yes', 'type': 'DIMM DDR3', 'size': '16384 MB'}, 'socket 10': {'status': 'Good, In Use', 'socket': 10, 'ranks': 2, 'technology': 'RDIMM', 'frequency': '1333 MHz', 'minimum_voltage': '1.35 v', 'hp_smart_memory': 'Yes', 'type': 'DIMM DDR3', 'size': '16384 MB'}, 'socket 12': {'status': 'Good, In Use', 'socket': 12, 'ranks': 2, 'technology': 'RDIMM', 'frequency': '1333 MHz', 'minimum_voltage': '1.35 v', 'hp_smart_memory': 'Yes', 'type': 'DIMM DDR3', 'size': '16384 MB'}}, 'CPU_1': {'socket 3': {'status': 'Good, In Use', 'socket': 3, 'ranks': 2, 'technology': 'RDIMM', 'frequency': '1333 MHz', 'minimum_voltage': '1.35 v', 'hp_smart_memory': 'Yes', 'type': 'DIMM DDR3', 'size': '16384 MB'}, 'socket 2': {'status': 'Good, In Use', 'socket': 2, 'ranks': 2, 'technology': 'RDIMM', 'frequency': '1333 MHz', 'minimum_voltage': '1.35 v', 'hp_smart_memory': 'Yes', 'type': 'DIMM DDR3', 'size': '16384 MB'}, 'socket 1': {'status': 'Good, In Use', 'socket': 1, 'ranks': 2, 'technology': 'RDIMM', 'frequency': '1333 MHz', 'minimum_voltage': '1.35 v', 'hp_smart_memory': 'Yes', 'type': 'DIMM DDR3', 'size': '16384 MB'}, 'socket 7': {'status': 'Good, In Use', 'socket': 7, 'ranks': 2, 'technology': 'RDIMM', 'frequency': '1333 MHz', 'minimum_voltage': '1.35 v', 'hp_smart_memory': 'Yes', 'type': 'DIMM DDR3', 'size': '16384 MB'}, 'socket 6': {'status': 'Good, In Use', 'socket': 6, 'ranks': 2, 'technology': 'RDIMM', 'frequency': '1333 MHz', 'minimum_voltage': '1.35 v', 'hp_smart_memory': 'Yes', 'type': 'DIMM DDR3', 'size': '16384 MB'}, 'socket 5': {'status': 'Good, In Use', 'socket': 5, 'ranks': 2, 'technology': 'RDIMM', 'frequency': '1333 MHz', 'minimum_voltage': '1.35 v', 'hp_smart_memory': 'Yes', 'type': 'DIMM DDR3', 'size': '16384 MB'}, 'socket 4': {'status': 'Good, In Use', 'socket': 4, 'ranks': 2, 'technology': 'RDIMM', 'frequency': '1333 MHz', 'minimum_voltage': '1.35 v', 'hp_smart_memory': 'Yes', 'type': 'DIMM DDR3', 'size': '16384 MB'}, 'socket 9': {'status': 'Good, In Use', 'socket': 9, 'ranks': 1, 'technology': 'RDIMM', 'frequency': '1333 MHz', 'minimum_voltage': '1.35 v', 'hp_smart_memory': 'Yes', 'type': 'DIMM DDR3', 'size': '4096 MB'}, 'socket 8': {'status': 'Good, In Use', 'socket': 8, 'ranks': 2, 'technology': 'RDIMM', 'frequency': '1333 MHz', 'minimum_voltage': '1.35 v', 'hp_smart_memory': 'Yes', 'type': 'DIMM DDR3', 'size': '16384 MB'}, 'socket 11': {'status': 'Good, In Use', 'socket': 11, 'ranks': 2, 'technology': 'RDIMM', 'frequency': '1333 MHz', 'minimum_voltage': '1.35 v', 'hp_smart_memory': 'Yes', 'type': 'DIMM DDR3', 'size': '16384 MB'}, 'socket 10': {'status': 'Good, In Use', 'socket': 10, 'ranks': 2, 'technology': 'RDIMM', 'frequency': '1333 MHz', 'minimum_voltage': '1.35 v', 'hp_smart_memory': 'Yes', 'type': 'DIMM DDR3', 'size': '16384 MB'}, 'socket 12': {'status': 'Good, In Use', 'socket': 12, 'ranks': 1, 'technology': 'RDIMM', 'frequency': '1333 MHz', 'minimum_voltage': '1.35 v', 'hp_smart_memory': 'Yes', 'type': 'DIMM DDR3', 'size': '4096 MB'}}}, 'advanced_memory_protection': {'configured_amp_mode': 'Advanced ECC', 'available_amp_modes': 'On-line Spare, Advanced ECC', 'amp_mode_status': 'Advanced ECC'}, 'memory_details_summary': {'cpu_2': {'operating_frequency': '1067 MHz', 'operating_voltage': '1.35 v', 'total_memory_size': '192 GB', 'number_of_sockets': 12}, 'cpu_1': {'operating_frequency': '1067 MHz', 'operating_voltage': '1.35 v', 'total_memory_size': '168 GB', 'number_of_sockets': 12}}}, 'firmware_information': {'HP ProLiant System ROM Bootblock': '03/11/2012', 'iLO': '1.13 Nov 08 2012', 'Power Management Controller Firmware Bootloader': '2.7', 'SAS Programmable Logic Device': 'Version 0x0C', 'HP ProLiant System ROM': '12/14/2012', 'Server Platform Services (SPS) Firmware': '2.1.5.2B.4', 'HP ProLiant System ROM - Backup': '12/14/2012', 'System Programmable Logic Device': 'Version 0x2D', 'HP Smart Array P420i Controller': '3.42', 'Power Management Controller Firmware': '3.0'}, 'power_supplies': {'Power Supply 2': {'status': 'OK', 'label': 'Power Supply 2'}, 'Power Supply 1': {'status': 'OK', 'label': 'Power Supply 1'}}, 'storage': {'Controller on System Board': {'status': 'OK', 'controller_status': 'OK', 'cache_module_memory': '1048576 KB', 'drive_enclosures': [{'status': 'OK', 'drive_bay': 4, 'label': 'Port 1I Box 2'}, {'status': 'OK', 'drive_bay': 4, 'label': 'Port 2I Box 0'}], 'logical_drives': [{'status': 'OK', 'fault_tolerance': 'RAID 1/RAID 1+0', 'capacity': '136 GB', 'physical_drives': [{'status': 'OK', 'capacity': '136 GB', 'fw_version': 'HPD3', 'label': 'Port 1I Box 2 Bay 1', 'location': 'Port 1I Box 2 Bay 1', 'serial_number': '6XM2R28Z0000B348CPGE', 'model': 'EH0146FBQDC'}, {'status': 'OK', 'capacity': '136 GB', 'fw_version': 'HPD3', 'label': 'Port 1I Box 2 Bay 2', 'location': 'Port 1I Box 2 Bay 2', 'serial_number': '6XM2QLK90000B348DF7V', 'model': 'EH0146FBQDC'}], 'label': '01'}], 'fw_version': '3.42', 'label': 'Controller on System Board', 'cache_module_status': 'OK', 'cache_module_serial_num': 'PBKUC0BRH4A62N', 'serial_number': '5001438025BB71A0', 'model': 'HP Smart Array P420i Controller'}}, 'nic_information': {'iLO Dedicated Network Port': {'network_port': 'iLO Dedicated Network Port', 'status': 'OK', 'port_description': 'iLO Dedicated Network Port', 'ip_address': '10.1.7.84', 'mac_address': '28:92:4a:34:ef:70'}, 'Port 4': {'network_port': 'Port 4', 'status': 'Other', 'port_description': 'N/A', 'ip_address': 'N/A', 'mac_address': 'ac:16:2d:84:56:bb'}, 'Port 3': {'network_port': 'Port 3', 'status': 'Other', 'port_description': 'N/A', 'ip_address': 'N/A', 'mac_address': 'ac:16:2d:84:56:ba'}, 'Port 2': {'network_port': 'Port 2', 'status': 'Other', 'port_description': 'N/A', 'ip_address': 'N/A', 'mac_address': 'ac:16:2d:84:56:b9'}, 'Port 1': {'network_port': 'Port 1', 'status': 'Other', 'port_description': 'N/A', 'ip_address': 'N/A', 'mac_address': 'ac:16:2d:84:56:b8'}}, 'vrm': None, 'processors': {'Proc 2': {'status': 'OK', 'internal_l1_cache': '192 KB', 'name': ' Intel(R) Xeon(R) CPU E5-2620 0 # 2.00GHz ', 'memory_technology': '64-bit Capable', 'internal_l2_cache': '1536 KB', 'label': 'Proc 2', 'internal_l3_cache': '15360 KB', 'speed': '2000 MHz', 'execution_technology': '6/6 cores; 12 threads'}, 'Proc 1': {'status': 'OK', 'internal_l1_cache': '192 KB', 'name': ' Intel(R) Xeon(R) CPU E5-2620 0 # 2.00GHz ', 'memory_technology': '64-bit Capable', 'internal_l2_cache': '1536 KB', 'label': 'Proc 1', 'internal_l3_cache': '15360 KB', 'speed': '2000 MHz', 'execution_technology': '6/6 cores; 12 threads'}}}
pprint module can help you.
8.18. pprint — Data pretty printer
The pprint module provides a capability to “pretty-print” arbitrary Python data structures in a form which can be used as input to the interpreter. If the formatted structures include objects which are not fundamental Python types, the representation may not be loadable. This may be the case if objects such as files, sockets, classes, or instances are included, as well as many other built-in objects which are not representable as Python constants.
The formatted representation keeps objects on a single line if it can, and breaks them onto multiple lines if they don’t fit within the allowed width. Construct PrettyPrinter objects explicitly if you need to adjust the width constraint.