Downloads FJC IDB files from the FJC website.
The FJC publishes each yearly file of the Integrated Database on a dataset page
for its case type (see options._DATASET_PAGES). The functions in this module
read those pages and save the yearly SAS files, and the codebook for each case
type, in the layout that run expects, creating any folders that do not exist
yet:
data_folder/
├── appellate/ ap08.sas7bdat, ...
├── district/
│ ├── civil/ cv08_0.sas7bdat, ...
│ └── criminal/ cr08.sas7bdat, ...
└── docs/ the codebooks
create_folders(data_folder=options._DATA_FOLDER)
¶
Creates the folders of the data folder that do not exist yet.
The data folder gets a folder for the yearly files of each case type and a 'docs' folder for the codebooks. Folders that already exist, and the files in them, are left as they are.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_folder
|
str | Path
|
The path to the folder containing the FJC IDB dataset. Defaults to options._DATA_FOLDER. |
_DATA_FOLDER
|
Returns:
| Type | Description |
|---|---|
list[Path]
|
list[pathlib.Path]: The folders of the data folder. |
Examples:
Source code in src/fjc_idb/downloader.py
download(case_type, start_year, stop_year=None, data_folder=options._DATA_FOLDER, *, overwrite=False, codebook=True)
¶
Downloads the yearly FJC IDB files for a range of years.
Files are saved under their FJC names (such as 'ap12_0.sas7bdat') in the
folder that run reads for case_type. A year that already has a file is
skipped unless overwrite is True, in which case its file is replaced. The
FJC updates the file for the current year during the year, so overwrite it
to get the latest data. Years the FJC has not published are skipped with a
warning. Any folders of the data folder that do not exist yet are created
(see create_folders).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
case_type
|
str
|
The source type ('appellate', 'civil', or 'criminal'). |
required |
start_year
|
int
|
The first statistical year to download. |
required |
stop_year
|
int | None
|
The last statistical year to download. Defaults to None, in which case the current year is used. |
None
|
data_folder
|
str | Path
|
The path to the folder containing the FJC IDB dataset. Defaults to options._DATA_FOLDER. |
_DATA_FOLDER
|
overwrite
|
bool
|
Whether to replace files that already exist. Defaults to False. |
False
|
codebook
|
bool
|
Whether to also download the codebook for |
True
|
Returns:
| Type | Description |
|---|---|
list[Path]
|
list[pathlib.Path]: The files that were downloaded. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Examples:
Source code in src/fjc_idb/downloader.py
list_files(case_type)
¶
Returns the yearly FJC IDB files the FJC publishes for a case type.
Only the files for single years are included, not the cumulative, multi-year, or twelve-months-ending-June files on the same page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
case_type
|
str
|
The source type ('appellate', 'civil', or 'criminal'). |
required |
Returns:
| Type | Description |
|---|---|
dict[int, str]
|
dict[int, str]: The address of each yearly file, keyed by its year. |