Tips: More Readable Data with pretty-print

code
python
beginner
tips
Author

Daniel Kick

Published

June 21, 2021

Here’s a tool that some may find useful when working with data that’s not yet in a [DataFrame]. It lets one “pretty-print” an object making any text that would wrap easier to read.

# [In]
print(results_dictionary)
print("\n --------------------------------------------- \n")
import pprint
pprint.PrettyPrinter(indent=4).pprint(results_dictionary)
# [Out]
{'active': True, 'additionalInfo:programDbId': '343', 'additionalInfo:programName': 'UC Davis', 'commonCropName': 'Cassava', 'contacts': None, 'culturalPractices': None, 'dataLinks': [], 
# ...
'trialDbId': '343', 'trialName': 'UC Davis'}
--------------------------------------------- 
{   'active': True,
    'additionalInfo:programDbId': '343',    'additionalInfo:programName': 'UC Davis',    'commonCropName': 'Cassava',    'contacts': None,    'culturalPractices': None,    'dataLinks': [],    # ...    'trialDbId': '343',    'trialName': 'UC Davis'}