-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathunzip_filings.py
39 lines (30 loc) · 1.01 KB
/
unzip_filings.py
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
import requests
import os
from datetime import datetime
from settings import *
# only unzip filings from current year
#CURRENT_YEAR = '2019'
# run all years with CURRENT_YEAR = '2'
CURRENT_YEAR = '2'
def makedir(directory):
if not os.path.exists(directory):
os.makedirs(directory)
if __name__ == '__main__':
infile = open(ELECTRONIC_ZIPFILE_MANIFEST, 'r')
filings = []
for raw_row in infile:
row = raw_row.replace("\n","")
if row.endswith(".zip"):
#print("'%s'" % row)
filings.append(row)
for i, filing in enumerate(filings):
raw_name = filing.replace(".zip", "")
directory_path = RAW_ELECTRONIC_DIR + raw_name
makedir(directory_path)
if CURRENT_YEAR in raw_name:
unzip_cmd = "unzip -o %s%s -d %s%s/" % (ELECTRONIC_ZIPDIR, filing, RAW_ELECTRONIC_DIR, raw_name)
print(i)
print(unzip_cmd)
os.system(unzip_cmd)
else:
print("Skipping zipfile %s" % raw_name)