<jupyter_start><jupyter_text>1. Loading the JSON file<jupyter_code>fd = open('JS.json','r')
txt = fd.read()
fd.close()<jupyter_output><empty_output><jupyter_text>2. Convert String to Dictionary<jupyter_code>import json

dct = json.loads(txt)<jupyter_output><empty_output><jupyter_text>3. Data Walkthrough<jupyter_code>dct.keys()
len(dct['data'])
dct['data'][0]
print("ID       : " , dct['data'][0]['id'])
print("URL      : " , dct['data'][0]['infoUrl'])
print("Name     : " , dct['data'][0]['name'])
print("TypeID   : " , dct['data'][0]['type']['id'])
print("TypeName : " , dct['data'][0]['type']['name'])<jupyter_output>ID       :  KS120P86XDXZJT3B7KVJ
URL      :  https://skills.emsidata.com/skills/KS120P86XDXZJT3B7KVJ
Name     :  (American Society For Quality) ASQ Certified
TypeID   :  ST3
TypeName :  Certification<jupyter_text>4. Convert Dictionary to List (NoSQL to SQL)<jupyter_code>data = []

for i in dct['data']:
    data.append([i['id'], i['infoUrl'], i['name'], i['type']['id'], i['type']['name']])<jupyter_output><empty_output><jupyter_text>5. Converting Multi-dimensional list to DataFrame<jupyter_code>import pandas as pd

df = pd.DataFrame(data, columns = ['id', 'url', 'name', 'type_id', 'type_name'])
df.head(<jupyter_output><empty_output><jupyter_text>6. Checking Null values in DataFrame<jupyter_code>df.isnull().sum()<jupyter_output><empty_output><jupyter_text>7. Saving CSV File<jupyter_code>df.to_csv('data.csv', index = False)<jupyter_output><empty_output><jupyter_text>8. Select only Name column in dataset<jupyter_code>final = []

for i in dct['data']:
    
    data = {}    
    data['name'] = i['name']
    
    final.append(data)
final[:10]
dct['attributions']
dct['data'] = final<jupyter_output><empty_output><jupyter_text>9. Checking Final Dictionary<jupyter_code>dct.keys()
dct['attributions']<jupyter_output><empty_output><jupyter_text>10. Converting Dictionary to JSON<jupyter_code>txt = json.dumps(dct)
type(txt)
len(txt)
txt[:100]
fd = open('JSON.json','w')

fd.write(txt)

fd.close()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18567251461988304, 'fraction_numerical': 0.018031189083820662, 'mean_word_length': 6.689138576779026, 'pattern_counts': {'":': 0, '<': 40, '<?xml version=': 0, '>': 40, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '646089', 'license': 'Apache-2.0', 'n_tokens_mistral': 835, 'n_tokens_neox': 817, 'n_words': 121, 'path': 'Week - 10/Dataset Conversion from Unstructured to Structured/Dataset Conversion from Unstructured to Structured.ipynb', 'repo_name': 'AshishJangra27/Data-Science-Specialization', 'size': '2052'}