SHARE
TWEET

Untitled

a guest Jun 26th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [4/30/18, 5:49:51 PM] β€ͺ+11 11 111 1111: Thanks for the recommendation.
  2. [4/30/18, 5:51:21 PM] Joe Johnson: It's a pleasure to know you!
  3. [4/30/18, 6:00:55 PM] β€ͺ+11 1 11 1111 1111: Nice!
  4. [4/30/18, 6:22:01 PM] β€ͺ+1 (111) 111‑111: sure.. I will look into.
  5.      
  6. date_regex = re.compile(r'(d+/d+/d+)')
  7. date = date_regex.findall(watsup_content)
  8. time_regex = re.compile(r'(d{1,2}:d{2}:d{2} AM|d{1,2}:d{2}:d{2} PM)')
  9. time = time_regex.findall(watsup_content)
  10.      
  11. import re
  12.  
  13. with open('myfile.txt', 'r') as f:
  14.     content = f.readlines()
  15.  
  16. date_regex = re.compile(r'(d+/d+/d+)')
  17. time_regex = re.compile(r'(d{1,2}:d{2}:d{2} AM|d{1,2}:d{2}:d{2} PM)')
  18.  
  19. for line in content:
  20.     print(line)
  21.     date = date_regex.findall(line)
  22.     time = time_regex.findall(line)
  23.     content = line.split(':')[-1].strip()
  24.     author = line.split(']')[-1].split(':')[0].strip()
  25.     print(date)
  26.     print(time)
  27.     print(author)
  28.     print(content)
  29.     print('---')
  30.      
  31. [4/30/18, 5:49:51 PM] β€ͺ+11 11 111 1111: Thanks for the recommendation.
  32.  
  33. ['4/30/18']
  34. ['5:49:51 PM']
  35. β€ͺ+11 11 111 1111
  36. Thanks for the recommendation.
  37. ---
  38. [4/30/18, 5:51:21 PM] Joe Johnson: It's a pleasure to know you!
  39.  
  40. ['4/30/18']
  41. ['5:51:21 PM']
  42. Joe Johnson
  43. It's a pleasure to know you!
  44. ---
  45. [4/30/18, 6:00:55 PM] β€ͺ+11 1 11 1111 1111: Nice!
  46.  
  47. ['4/30/18']
  48. ['6:00:55 PM']
  49. β€ͺ+11 1 11 1111 1111
  50. Nice!
  51. ---
  52. [4/30/18, 6:22:01 PM] β€ͺ+1 (111) 111‑111: sure.. I will look into.
  53.  
  54. ['4/30/18']
  55. ['6:22:01 PM']
  56. β€ͺ+1 (111) 111‑111
  57. sure.. I will look into.
  58. ---
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top