-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreadthedata.py
More file actions
79 lines (70 loc) · 2.51 KB
/
readthedata.py
File metadata and controls
79 lines (70 loc) · 2.51 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import csv
with open('filedata.csv') as datareader:
readss = csv.reader(datareader,delimiter=':')
data=list(readss)
dateChanged={}
dateModify={}
headers=data.pop(0)
for file in data:
#Add files in groups to the dateChanged
try:
if file[1].split()[0] in dateChanged:
dateChanged[file[1].split()[0]].append([file[0],file[1].split()[1]])
else:
dateChanged[file[1].split()[0]]=[]
dateChanged[file[1].split()[0]].append([file[0],file[1].split()[1]])
except:
pass
#Add files in groups to the dateModify
try:
if file[2].split()[0] in dateModify:
dateModify[file[2].split()[0]].append([file[0], file[2].split()[1]])
else:
dateModify[file[2].split()[0]]=[]
dateModify[file[2].split()[0]].append([file[0], file[2].split()[1]])
except:
pass
ques="asdfghjkl;"
currDirectory = "/"
while ques.lower()!="done":
try:
if ques.lower()=="changed date list":
for date in sorted(dateChanged):
length = 0
for f in dateChanged[date]:
if currDirectory in f[0]:
length += 1
print(date+': '+str(length))
elif ques.lower()=="modified date list":
for date in sorted(dateModify):
length = 0
for f in dateChanged[date]:
if currDirectory in f[0]:
length += 1
print(date+': '+str(length))
elif ques.lower()=="datemodify":
ques2=input("Which modified date(EX| 2020-04-29)? ")
for file in dateModify[ques2]:
if currDirectory in file[0]:
print(file[0],file[1])
elif ques.lower()=="datechanged":
ques2=input("Which changed date(EX| 2020-04-29)? ")
for file in dateChanged[ques2]:
if currDirectory in file[0]:
print(file[0],file[1])
elif ques.lower()=="change directory":
ques2=input("Which directory do you want to only read from(EX| /etc)?")
currDirectory = ques2
else:
if 'path' in ques.lower() and 'filename' in ques.lower():
ques=input("What is the path and filename(EX| /home/John/hi.txt) or for contents in path(EX| /home/John/)? ")
for file in data:
if file[0] in ques or ques in file[0]:
print("%s, 'ChangedDate:%s', 'ModifiedDate:%s'"%(file[0],file[1],file[2]))
if ques[-1]!="/":
break
except Exception as e:
print(e)
print("\nchanged date list, datechanged, modified date list, datemodify, 'path + filename', date grouper, change directory, done")
print("Current directory is " + currDirectory)
ques=input("What is it you wanna do? ")