-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfind.py
More file actions
26 lines (19 loc) · 720 Bytes
/
Copy pathfind.py
File metadata and controls
26 lines (19 loc) · 720 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
import os
import re
def none_filter(text, pattern):
return list(filter(None, re.split(pattern, text)))
# start = str_emaz.find('sa', start=start, end=end)
def main():
fn = os.path.join(os.path.dirname(__file__),
'COMM7330_Quiz05_datasetS2.csv')
with open(fn, 'rb') as fr:
exam = fr.read().decode('utf-8', 'ignore').strip()
exam_list = none_filter(exam, ' |\?|\r|\n|\!|,|\)|\'')
result_0 = [e for e in exam_list if e[0] == '@']
print(result_0)
result_1 = [e for e in exam_list if e[0] == '#']
print(result_1)
result_2 = [e for e in exam_list if e[:4] == 'http']
print(result_2)
if __name__ == "__main__":
main()