forked from mdlincoln/caselaw-to-sqlite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extract.sh
executable file
·49 lines (36 loc) · 1.62 KB
/
extract.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
set -e
function case_law {
echo -ne "extracting cases..."
xzcat "$1" | jq -r '[.id, .name, .name_abbreviation, .decision_date, .docket_number, .first_page, .last_page, .volume.volume_number, .reporter.full_name, .court.id, .jurisdiction.id, .casebody.status, .casebody.data.head_matter] | @csv' > cases.csv
echo "done"
echo -ne "extracting citations..."
xzcat "$1" | jq -r '{"id": .id, "citations": .citations[]} | [.id, .citations.type, .citations.cite] | @csv' > citations.csv
echo "done"
echo -ne "extracting courts..."
xzcat "$1" | jq -r '.court | [.id, .name, .name_abbreviation, .jurisdiction.url, .slug] | @csv' > courts.csv
echo "done"
echo -ne "extracting jurisdictions..."
xzcat "$1" | jq -r '.jurisdiction | [.id, .slug, .name, .name_long, .whitelisted] | @csv' > jurisdictions.csv
echo "done"
echo -ne "extracting opinions..."
xzcat "$1" | jq -r '{"id": .id, "opinion": .casebody.data.opinions[]} | [.id, .opinion.type, .opinion.text, .opinion.author] | @csv' > opinions.csv
echo "done"
echo -ne "extracting parties..."
xzcat "$1" | jq -r '{"id": .id, "obj": .casebody.data.parties[]} | [.id, .obj] | @csv' > parties.csv
echo "done"
echo -ne "extracting attorneys..."
xzcat "$1" | jq -r '{"id": .id, "obj": .casebody.data.attorneys[]} | [.id, .obj] | @csv' > attorneys.csv
echo "done"
echo -ne "extracting judges"
xzcat "$1" | jq -r '{"id": .id, "obj": .casebody.data.judges[]} | [.id, .obj] | @csv' > judges.csv
echo "done"
echo "Loading into caselaw.sqlite"
sqlite3 -bail -echo caselaw.sqlite ".read import.sql"
}
while [ $# -ne 0 ]
do
echo "Current Parameter: '$1' , Remaining $#"
case_law "$1"
shift
done