<jupyter_start><jupyter_text>Bulk case download and extract<jupyter_code>import os
import sys
sys.path.append('..')

import lzma
import json
import pandas as pd

from config import settings
import utils
jurisdiction_to_load = 'Illinois'
dir_exists = False
dir_path = None
for filename in os.listdir(settings.DATA_DIR):
    if jurisdiction_to_load in filename:
        if os.path.exists(os.path.join(settings.DATA_DIR, filename + '/data/data.jsonl.xz')):
            dir_exists = True
            break
if dir_exists:
    dir_path = os.path.join(settings.DATA_DIR, filename)
else:
    dir_path = utils.get_cases_from_bulk('Illinois')
compressed_file = os.path.join(settings.DATA_DIR, dir_path + '/data/data.jsonl.xz')
os.path.exists(compressed_file)
cases = []
print(compressed_file)
with lzma.open(compressed_file) as infile:
    for line in infile:
        record = json.loads(str(line, 'utf-8'))
        cases.append(record)

print("Case count: %s" % len(cases))
df = pd.DataFrame(cases)
df.head()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11661807580174927, 'fraction_numerical': 0.0009718172983479105, 'mean_word_length': 4.33678756476684, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '197405', 'license': 'MIT', 'n_tokens_mistral': 364, 'n_tokens_neox': 360, 'n_words': 78, 'path': 'bulk_extract/extract_cases.ipynb', 'repo_name': 'abziegler/cap-examples', 'size': '1029'}