File: slicecat

package info (click to toggle)
python-ceres 0.10.0~git20130913-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 200 kB
  • ctags: 232
  • sloc: python: 1,156; makefile: 126
file content (31 lines) | stat: -rwxr-xr-x 643 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/python

import sys
import os
import time
import struct
from optparse import OptionParser


parser = OptionParser(usage='%prog [options] <path>')

options, args = parser.parse_args()

if not args:
  parser.print_usage()
  sys.exit(1)

path = args[0]

filename = os.path.basename(path)
timestamp, timeStep = filename[:-6].split('@', 1)
timestamp, timeStep = int(timestamp), int(timeStep)

packedValues = open(path, 'rb').read()
format = '!' + ('d' * (len(packedValues) / 8))

values = struct.unpack(format, packedValues)

for value in values:
  print "[%d]\t%s\t%s" % (timestamp, time.ctime(timestamp), value)
  timestamp += timeStep