Skip to content

Instantly share code, notes, and snippets.

@ryo1kato
Created November 29, 2012 01:28
Show Gist options
  • Save ryo1kato/4166132 to your computer and use it in GitHub Desktop.
Save ryo1kato/4166132 to your computer and use it in GitHub Desktop.
convert unix epoch time to Excel time
#!/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