Created
December 12, 2010 23:41
-
-
Save gburd/738469 to your computer and use it in GitHub Desktop.
Combines JBookTrader marketData log files.
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/env python | |
# Author Gregory Burd <gburd@ossus.com> | |
# | |
# The author places this work into the public domain. | |
# http://creativecommons.org/licenses/publicdomain/ | |
import sys, re | |
count = len(sys.argv) | |
files = [] | |
d = {} | |
p = re.compile('^[0-9]') | |
# Open the files | |
for i in range(len(sys.argv) - 1): | |
files.append(open(sys.argv[i + 1], "r")) | |
# Skip the first 10 lines of each file | |
for i in range(len(sys.argv) - 1): | |
for line in files[i]: | |
if p.match(line): | |
l = line.strip().split( "," ) | |
k = l[0] + l[1] | |
d[k] = l | |
print """# This historical data file was created by JBookTrader, version 8.02 | |
# Each line represents a 1-second snapshot of the market and contains 5 columns: | |
# 1. date in the MMddyy format | |
# 2. time in the HHmmss format | |
# 3. book balance | |
# 4. price | |
# 5. volume | |
timeZone=America/New_York | |
""" | |
# Output the sorted values from the dictionary | |
for r in [d[k] for k in sorted(d.keys())]: | |
print r[0] + "," + r[1] + "," + r[2] + "," + r[3] + "," + r[4] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment