-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-dic.py.save
106 lines (83 loc) · 2.38 KB
/
test-dic.py.save
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/python
# Python version of RaceImport
# Restarted 8/23/15
# Steve
# opens defined file
# fills dictionary with run data
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-i', dest='infile', help="input file", metavar='INPUT_FILE')
parser.add_argument('-o', dest='outdir', help="output directory", metavar='OUTPUT_DIR')
args = parser.parse_args()
run=dict()
with open(args.infile,"r") as infile:
for line in infile:
# Run Number
if line.find("RUN:",0) > -1:
run['Num']=line[4:9]
run['DateTime']=line[13:36]
# Round, Class, and Type
if line.find("RD#",0) > -1:
run['Class']=line[0:19]
run['Round']=line[28:36]
run['Type']=line[18:27]
# Car Numbers. Advances line and takes names
if line.find("LEFT:",0) > -1:
run['LeftNum']=line[6:17]
run['RightNum']=line[33:36]
line = next(infile)
run['LeftName']=line[0:17]
run['RightName']=line[18:36]
# Dial Ins
if line.find("DIAL IN",0) > -1:
run['LeftDial']=line[0:7]
run['RightDial']=line[28:36]
# Reaction
if line.find("REACTION",0) > -1:
run['LeftReaction']=line[0:7]
run['RightReaction']=line[28:36]
# 60 Ft
if line.find("60 FT",0) > -1:
run['Left60FT']=line[0:7]
run['Right60FT']=line[28:36]
# ET
if line.find("300 ET",0) > -1:
run['LeftET']=line[0:7]
run['RightET']=line[28:36]
# MPH
if line.find("300 MPH",0) > -1:
run['LeftMPH']=line[0:7]
run['RightMPH']=line[28:36]
# Margin and Result
if line.find("FINISH MARGIN",0) > -1:
run['LeftMargin']=line[0:7]
run['RightMargin']=line[28:36]
line = next(infile)
if line.find("OFF DIAL",0) > -1:
run['LeftOffDial']=line[0:7]
run['RightOffdial']=line[28:36]
line = next(infile)
run['LeftResult']=line[0:17]
run['RightResult']=line[18:36]
else:
run['LeftResult']=line[0:17]
run['RightResult']=line[18:36]
for key in run:
if key == 'RightNum':
print key, '=', run[key].strip(':')
elif key == 'Round':
print key, '=', run[key].strip('RD# ')
else:
print key, '=', run[key].strip()
run.clear()
# print run['Num'].strip()
# print run['DateTime'].strip()
# print run['Class'].strip()
# print run['Round'].strip('RD# ')
# print run['Type'].strip()
# print run['LeftNum']
# print run['RightNum'].strip(':')
# print run['LeftName'].strip()
# print run['RightName'].strip()
infile.close()
print 'FileName: ' + +