Created
November 29, 2012 01:28
-
-
Save ryo1kato/4166132 to your computer and use it in GitHub Desktop.
convert unix epoch time to Excel time
This file contains hidden or 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/env python | |
# | |
# Read a CSV file from STDIN, assume the 1st column is unix-seconds | |
# convert it to excel time value ( (UNIXSEC + 32400) / 86400 + 25569 ) | |
# and insert it as 2nd column | |
# | |
import sys | |
for line in sys.stdin.readlines(): | |
(unixsec_str, delim, rest) = line.partition(',') | |
exceltime = (int(unixsec_str) + 32400.0) / 86400.0 + 25569.0 | |
print "%s,%f,%s" % (unixsec_str, exceltime, rest.rstrip('\n')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment