-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDateRangeFinder.py
More file actions
39 lines (30 loc) · 814 Bytes
/
DateRangeFinder.py
File metadata and controls
39 lines (30 loc) · 814 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
32
33
34
35
36
37
38
#!/usr/bin/env python
# coding: utf-8
# In[1]:
#Assinment: In class date range filer
# SELECT * FROM cddata WHERE Date >= 2019-01-01 and Date <= 2019-01-20
import sys
import os
import json
import time
import datetime
import operator
f2 = open('output.txt', 'w')
f2.write('\n')
f2.close()
f2 = open('output.txt', 'a')
for root, dirs, files in os.walk('data'):
# print(root,dirs,files)
path = root.split(os.sep)
for fn in files:
fp = root+os.sep+fn
print(fp)
f = open(fp, 'r')
for line in f:
data = json.loads(line)
payload = data['payload']
payload = json.loads(payload)
k = payload['received'].split('T')[0]
if k >= '2019-01-01' and k <= '2019-01-02':
f2.write(line + '\n')
f2.close()