/
partition.py
28 lines (22 loc) · 1.1 KB
/
partition.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
#======================================#
# BabyNamer #
# by Randall Arms #
# github.com/randallarms/babynamer #
#======================================#
# This program creates a directory for the range of years specified, and adds a
# blank text document named "unsorted" to each one, so I don't have to do it manually. >:)
import os
# Get file location and contents
__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
__names_location__ = os.path.join(__location__, "names/")
contents = os.listdir(__names_location__)
# Create directories
y1 = 1880 # Earliest year that the records are available from the SSA website
y2 = 2020 # Most recent year that the records are available from the SSA website, +1
for y in range(y1, y2):
__y_location__ = os.path.join(__names_location__, str(y) + "/")
__unsorted_location__ = os.path.join(__y_location__, "unsorted.txt/")
if not str(y) in contents:
os.mkdir(__y_location__)
unsorted = open(os.path.join(__y_location__, "unsorted.txt"), "w")
unsorted.close()