Advertisement
cuteSquirrel

Catch USRP timestamp

Mar 24th, 2021 (edited)
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. import re
  2.  
  3. path = 'date.txt'
  4.  
  5. with open(path) as f:
  6.  
  7.     for line in f:
  8.        
  9.         # catch USRP timestamp by regular expression
  10.         pattern = re.compile( r'\b(\d+\.\d+)\b' )
  11.         result = re.search(pattern, line)
  12.  
  13.         if result:
  14.  
  15.             timestamp_str = result.groups(1)[0]
  16.  
  17.             print("\n")
  18.             print( type(timestamp_str) )
  19.             print(f"string result {timestamp_str}" )
  20.  
  21.             # convert from string to float
  22.             timestamp_float = float(timestamp_str)
  23.  
  24.             print("\n")
  25.             print( type(timestamp_float) )
  26.             print(f" float result {timestamp_float:.9f}" )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement