Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [4/30/18, 5:49:51 PM] +11 11 111 1111: Thanks for the recommendation.
- [4/30/18, 5:51:21 PM] Joe Johnson: It's a pleasure to know you!
- [4/30/18, 6:00:55 PM] +11 1 11 1111 1111: Nice!
- [4/30/18, 6:22:01 PM] +1 (111) 111‑111: sure.. I will look into.
- date_regex = re.compile(r'(d+/d+/d+)')
- date = date_regex.findall(watsup_content)
- time_regex = re.compile(r'(d{1,2}:d{2}:d{2} AM|d{1,2}:d{2}:d{2} PM)')
- time = time_regex.findall(watsup_content)
- import re
- with open('myfile.txt', 'r') as f:
- content = f.readlines()
- date_regex = re.compile(r'(d+/d+/d+)')
- time_regex = re.compile(r'(d{1,2}:d{2}:d{2} AM|d{1,2}:d{2}:d{2} PM)')
- for line in content:
- print(line)
- date = date_regex.findall(line)
- time = time_regex.findall(line)
- content = line.split(':')[-1].strip()
- author = line.split(']')[-1].split(':')[0].strip()
- print(date)
- print(time)
- print(author)
- print(content)
- print('---')
- [4/30/18, 5:49:51 PM] +11 11 111 1111: Thanks for the recommendation.
- ['4/30/18']
- ['5:49:51 PM']
- +11 11 111 1111
- Thanks for the recommendation.
- ---
- [4/30/18, 5:51:21 PM] Joe Johnson: It's a pleasure to know you!
- ['4/30/18']
- ['5:51:21 PM']
- Joe Johnson
- It's a pleasure to know you!
- ---
- [4/30/18, 6:00:55 PM] +11 1 11 1111 1111: Nice!
- ['4/30/18']
- ['6:00:55 PM']
- +11 1 11 1111 1111
- Nice!
- ---
- [4/30/18, 6:22:01 PM] +1 (111) 111‑111: sure.. I will look into.
- ['4/30/18']
- ['6:22:01 PM']
- +1 (111) 111‑111
- sure.. I will look into.
- ---
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement