Last active
August 4, 2017 05:45
-
-
Save kndt84/891dcbc0fff6528eccd08fa39bd15e21 to your computer and use it in GitHub Desktop.
Add unixtime to first column
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import csv | |
import sys | |
import re | |
fps=10 | |
filename=sys.argv[1] | |
start_unixtime=int(re.search(r'(\d+)\.txt', filename).group(1)) | |
for i, line in enumerate(open(filename, 'r')): | |
if i==0: | |
continue # skip first row | |
elements = line.rstrip().split(' ') | |
unix_time = start_unixtime+int(elements[0])/float(fps) | |
elements.insert(0, str(unix_time)) | |
newline=','.join(elements) | |
print(newline) |
Author
kndt84
commented
Aug 4, 2017
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment