-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfindyear.py
More file actions
31 lines (24 loc) · 956 Bytes
/
Copy pathfindyear.py
File metadata and controls
31 lines (24 loc) · 956 Bytes
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
fileList = open("fileList.txt", "r")
fileName = fileList.readlines()
fileList.close()
startyear = 1900
endyear = 2017
outfile = open("year.txt", "w")
for i in range(len(fileName)):
oneFile = open(fileName[i].rstrip(), "r")
oneFileContent = oneFile.readlines()
oneFile.close()
for j in range(len(oneFileContent)):
yearList = []
isName = False
for k in range(len(oneFileContent[j]) - 3):
if '\"' in oneFileContent[j][k:k+4] or '\'' in oneFileContent[j][k:k+4]:
isName = not isName
continue
if (oneFileContent[j][k:k+4]).isdigit() and (not isName):
year = int(oneFileContent[j][k:k+4])
if year <= endyear and year >= startyear:
yearList.append(str(year))
if len(yearList) > 0:
outfile.write(yearList[len(yearList) - 1] + '\n')
outfile.close()