CoolFace
Datasetpublic

endomorphosis/Caselaw_Access_Project_JSON

The Caselaw Access Project In collaboration with Ravel Law, Harvard Law Library digitized over 40 million U.S. court decisions consisting of 6.7 million cases from the last 360 years into a dataset that is widely accessible to use. Access a bulk download of the data through the Caselaw Access Project API (CAPAPI): https://case.law/caselaw/ Find more information about accessing state and federal written court decisions of common law through the bulk data service… See the full description on the dataset page: https://huggingface.co/datasets/endomorphosis/Caselaw_Access_Project_JSON.

sourceHugging Facecc0-1.0updated 2y agoView on Hugging Face
3likes5.1kdownloads
paraquet_to_json.py37 linesDownload Raw Back to root
1import pandas as pd2import pyarrow.parquet as pq3import os4import json5import pathlib6 7this_dir = os.path.dirname(os.path.abspath(__file__))8folders = []9for folder in os.listdir(this_dir):10    if os.path.isdir(os.path.join(this_dir, folder)):11        print(os.path.join(this_dir, folder))12        folders.append(os.path.join(this_dir, folder))13 14for this_folder in folders:15    this_path = this_folder16    print(this_path)17    for file in os.listdir(this_path):18        print(file)19        if file.endswith(".parquet"):20            this_file = os.path.join(this_path, file)21            print(this_file)22            # Read the Parquet file23            data = pq.read_table(this_file)24 25            # Convert to pandas DataFrame26            df = data.to_pandas()27            del data28            # Convert to JSON29            json_data = df.to_json(orient='records')30            del df31            json_data = json.loads(json_data)32            for i in json_data:33                id = i['id']34                data = json.dumps(i)35                with open(f'{this_path}/{id}.json', 'w') as f:36                    json.dump(data, f)37