This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #!/usr/bin/env python3 | |
| import ast | |
| import os | |
| from collections import defaultdict | |
| from typing import List, Dict, Set, Tuple | |
| import sys | |
| class FunctionVisitor(ast.NodeVisitor): | |
| def __init__(self, file_path: str): | |
| self.file_path = file_path | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # !/bin/bash | |
| # Step 1. Install pyenv | |
| git clone https://github.com/pyenv/pyenv.git ~/.pyenv | |
| echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc | |
| echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc | |
| echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bashrc | |
| source ~/.bashrc | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import logging | |
| from pathlib import Path | |
| from shutil import unpack_archive | |
| import os | |
| import sys | |
| zip_files = Path(f"{sys.argv[1]}").rglob("*.zip") | |
| while True: | |
| try: | |
| path = next(zip_files) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import json | |
| from pandas.io.json import json_normalize | |
| import pandas as pd | |
| with open('C:\filename.json') as f: | |
| data = json.load(f) | |
| df = pd.DataFrame(data) | |
| normalized_df = json_normalize(df['nested_json_object']) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | from itertools import chain, starmap | |
| def flatten_json_iterative_solution(dictionary): | |
| """Flatten a nested json file""" | |
| def unpack(parent_key, parent_value): | |
| """Unpack one level of nesting in json file""" | |
| # Unpack one level only!!! | |
| if isinstance(parent_value, dict): | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # Reading input function with validation | |
| def read_int_input(prompt): | |
| try: | |
| target = int(input(prompt)) | |
| except ValueError: | |
| print("not an int! Please try again") | |
| return read_int_input(prompt) | |
| # Since it's a recursive function and assuming the sanity of the user, it's assumed that the wrong input won't be | |
| # passed more than thousand times. Since the recursive functions have some limits and the above, although correct, | |
| # will throw a runtime error of max space reached or something similar. | 

