Python Forum
Trouble with reading csv file and putting it into a file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trouble with reading csv file and putting it into a file
#1
I am reading a csv file. I am then putting it into a dictionary and then trying to put the Dictionary into a list. Problem is, in the file I am reading there should be 8 different dictionaries put in the list. But the only one that shows up is the last one, number 8. Anyway here is the code.
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# DEFINE LOAD RACE FILE FUNCTION
def load_racefiles() :
    count = 0
    master_race_file = []
    rows = 100
    columns = 100
    horse_array = [0 for i in range(rows)]
    file_name = StringVar()
    f_name = StringVar()
    #file_dir = (r"C:\2020")
    fd =    open("dirpath", "r")
    file_dir = (fd.read())
    fd.close()
    os.chdir(file_dir)
    for f in os.listdir(file_dir):
        file_name, file_ext = os.path.splitext(f)
        f_name = file_name + file_ext
        file_name = file_name.strip()[3:]
        line_counter = 0
        if file_name == Race_date and file_ext == ".jcp":
            with open(f_name, "r") as csv_file:
                csv_reader = csv.reader(csv_file)
                 
                for line in csv_reader:
                     
                     
                     
 
                    track_name = line[0]
                    race_num =  line[2]
                    surface =  line[6]
                    race_type =  line[8]
                    purse = line[11]
                    trn_starts_curmeet = line[28]
                    trn_wins_curmeet = line[29]
                    jock_sts_curmeet =  line[34]
                    jock_wins_curmeet =  line[35]
                    trn_starts_curyear = line[1146]
                    trn_wins_curyear = line[1147]
                    jock_sts_curyear =  line[1156]
                    jock_wins_curyear =  line[1157]
                    trn_starts_prevyear = line[1151]
                    trn_wins_prevyear = line[1152]
                    jock_sts_prevyear =  line[1161]
                    jock_wins_prevyear =  line[1162]
                    morn_line = line[43]
                    horse_name  = line[44]
                    year_of_birth = line[45]
                    hstarts_todays_dist = line[64]
                    hwins_todays_dist = line[65]
                    hstarts_todays_track = line[69]
                    hwins_todays_track = line[70]
                    hstarts_turf = line[74]
                    hwins_turf = line[75]
                    hstarts_mud = line[79]
                    hwins_mud = line[80]
                    hstarts_cur_yr = line[84]
                    hwins_cur_yr = line[85]
                    hstarts_prev_yr = line[90]
                    hwins_prev_yr = line[91]
                    hstarts_life = line[96]
                    hwins_life = line[97]
                    days_since = line[223]
                    power_rating = line[250]
                    dist_yards1 = line[315]
                    dist_yards2 = line[316]
                    dist_yards3 = line[317]
                    dist_yards4 = line[318]
                    dist_yards5 = line[319]
                    dist_yards6 = line[320]
                    dist_yards7 = line[321]
                    dist_yards8 = line[322]
                    dist_yards9 = line[323]
                    dist_yards10 = line[324]
                    surface1 = line[325]
                    surface2 = line[326]
                    surface3 = line[327]
                    surface4 = line[328]
                    surface5 = line[329]
                    surface6 = line[330]
                    surface7 = line[331]
                    surface8 = line[332]
                    surface9 = line[333]
                    surface10 = line[334]
                    entrants1 =  line[345]
                    entrants2 =  line[346]
                    entrants3 =  line[347]
                    entrants4 =  line[348]
                    entrants5 =  line[349]
                    entrants6 =  line[350]
                    entrants7 =  line[351]
                    entrants8 =  line[352]
                    entrants9 =  line[353]
                    entrants10 =  line[354]
                    first_call1 = line[575]
                    first_call2 = line[576]
                    first_call3 = line[577]
                    first_call4 = line[578]
                    first_call5 = line[579]
                    first_call6 = line[580]
                    first_call7 = line[581]
                    first_call8 = line[582]
                    first_call9 = line[583]
                    first_call10 = line[584]
                    second_call1 = line[585]
                    second_call2 = line[586]
                    second_call3 = line[587]
                    second_call4 = line[588]
                    second_call5 = line[589]
                    second_call6 = line[590]
                    second_call7 = line[591]
                    second_call8 = line[592]
                    second_call9 = line[593]
                    second_call0 = line[594]
                    finish_Position = line[615]
                    last_peed = line[845]
                    speed_2back = line[846]
                    speed_3back = line[847]
                    bestSpeed_Life  = line[1327]
                    bestSpeed_Fasttrack = line[1177]
                    bestSpeed_turf = line[1178]
                    bestSpeed_offtrack = line[1179]
                    bestSpeed_dist = line[1180]
                    race_conditions = line[15]
                    todays_race_classification = line[10]
                     
                     
 
                     
                    h = {'track' : track_name,
                    'race_number' : race_num,
                    'todays_surface' : surface,
                    'race_type' : race_type,
                    'todays_purse' : purse,
                    'trn_starts_curmeet' : trn_starts_curmeet,
                    'trn_wins_curmeet' : trn_wins_curmeet,
                    'jock_sts_curmeet' : jock_sts_curmeet,
                    'jock_wins_curmeet' : jock_wins_curmeet,
                    'trn_starts_prevyear' : trn_starts_prevyear,
                    'trn_wins_prevyear' : trn_wins_prevyear,
                    'jock_sts_prevyear' : jock_sts_prevyear,
                    'jock_wins_prevyear' : jock_wins_prevyear,
                    'morn_line' : morn_line,
                    'horse_name' : horse_name,
                    'year_of_birth' : year_of_birth,
                    'hstarts_todays_dist' : hstarts_todays_dist,
                    'hwins_todays_dist ' : hwins_todays_dist,
                    'hstarts_todays_track' : hstarts_todays_track,
                    'hwins_todays_track' :hwins_todays_track,
                    'hstarts_turf' : hstarts_turf,
                    'hwins_turf' : hwins_turf,
                    'hstarts_mud' : hstarts_mud,
                    'hwins_mud' : hwins_mud,
                    'hstarts_cur_yr' : hstarts_cur_yr,
                    'hwins_cur_yr' : hwins_cur_yr,
                    'hstarts_prev_yr' : hstarts_cur_yr,
                    'hwins_prev_yr' : hwins_cur_yr,
                    'hstarts_life' : hstarts_life,
                    'hwins_life' : hwins_life,
                    'days_since' : days_since,
                    'power_rating' : power_rating,
                    'dist_yards1' : dist_yards1,
                    'dist_yards2' : dist_yards2,
                    'dist_yards3' : dist_yards3,
                    'dist_yards4' : dist_yards4,
                    'dist_yards5' : dist_yards5,
                    'dist_yards6' : dist_yards6,
                    'dist_yards7' : dist_yards7,
                    'dist_yards8' : dist_yards8,
                    'dist_yards9' : dist_yards9,
                    'dist_yards10' : dist_yards10,
                    'surface1' : surface1,
                    'surface2' : surface2,
                    'surface3' : surface3,
                    'surface4' : surface4,
                    'surface5' : surface5,
                    'surface6' : surface6,
                    'surface7' : surface7,
                    'surface8' : surface8,
                    'surface9' : surface8,
                    'surface10' : surface10,
                    'entrants1' : entrants1,
                    'entrants2' : entrants2,
                    'entrants3' : entrants3,
                    'entrants4' : entrants4,
                    'entrants5' : entrants5,
                    'entrants6' : entrants6,
                    'entrants7' : entrants7,
                    'entrants8' : entrants8,
                    'entrants9' : entrants9,
                    'entrants10' : entrants10,
                    'first_call1' : first_call1,
                    'first_call2' : first_call2,
                    'first_call3' : first_call3,
                    'first_call4' : first_call4,
                    'first_call5' : first_call5,
                    'first_call6' : first_call6,
                    'first_call7' : first_call7,
                    'first_call8' : first_call8,
                    'first_call9' : first_call9,
                    'first_call10' : first_call10,
                    'second_call1' : second_call1,
                    'second_call2' : second_call2,
                    'second_call3' : second_call3,
                    'second_call4' : second_call4,
                    'second_call5' : second_call5,
                    'second_call6' : second_call6,
                    'second_call7' : second_call7,
                    'second_call8' : second_call8,
                    'second_call9' : second_call9,
                    'second_call0' : second_call0,
                    'finish_Position' : finish_Position,
                    'last_peed' : last_peed,
                    'speed_2back' : speed_2back,
                    'speed_3back' : speed_3back,
                    'trn_starts_curyear' : trn_starts_curyear,
                    'trn_wins_curyear' : trn_wins_curyear,
                    'jock_sts_curyear' : jock_sts_curyear,
                    'jock_wins_curyear' : jock_wins_curyear,
                    'bestSpeed_Life' : bestSpeed_Life,
                    'bestSpeed_Fasttrack' : bestSpeed_Fasttrack,
                    'bestSpeed_turf' : bestSpeed_turf,
                    'bestSpeed_offtrack' : bestSpeed_offtrack,
                    'bestSpeed_dist' : bestSpeed_dist,
                    'race_conditions' : race_conditions,
                    'todays_race_classification' : todays_race_classification
 
                     
 
                 
                        }
 
                master_race_file.append(h )
                line_counter +=1
                 
     
                         
                 
 
 
    print(master_race_file)
    print(line_counter)
                                 
                         
    my_labeldone= Label( text ="Downloading Complete", fg= "black", font = ("sans_serif" , 16)).place(x=500, y=500)                
 
   
I don't understand why just the last one prints out when I print the whole list.
Reply
#2
please show complete code, including imports.
Reply
#3
Here is the complete code.

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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
from tkinter import *
from tkinter import ttk
import time
from  tkinter import messagebox
import glob
import os
import shutil
import csv
import array as arr
import sqlite3
import pandas as pd
import numpy as np
 
 
 
 
 
 
 
 
 
 
 
root = Tk()
 
root.title("Handifast Version 13.0")
 
root.iconbitmap("c:/guis/racehorse.ico")
 
width_of_window = 1100
height_of_window = 700
     
 
screen_width= root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
x_coordinate = (screen_width/2) - (width_of_window/2)
y_coordinate = (screen_height/2) - (height_of_window/2)
root.geometry("%dx%d+%d+%d" % (width_of_window,height_of_window,x_coordinate,y_coordinate ))
 
 
#my_progress = ttk.Progressbar(root, orient = HORIZONTAL, length = 300, mode = 'determinate')
 
#my_progress.pack(pady=300)
 
#my_progress_label = Label(root, text = "")
#my_progress_label.pack(pady=350)
 
 
 
 
def save_path():
    global fyle_path
    fyle_path = entry_1.get()
    with open('dirpath', 'w') as f:
        f.write(fyle_path )
         
 
#DEFINE SAVE PATH
def setup_command():
    global entry_1
 
 
    top = Toplevel()
 
    width_of_window = 300
    height_of_window = 500
 
    screen_width= top.winfo_screenwidth()
    screen_height = top.winfo_screenheight()
    x_coordinate = (screen_width/2) - (width_of_window/2)
    y_coordinate = (screen_height/2) - (height_of_window/2)
    fyle_path = StringVar()
    entry_1 = StringVar()
    top.title("Directory Path")
    top.geometry("%dx%d+%d+%d" % (width_of_window,height_of_window,x_coordinate,y_coordinate ))
    my_label= Label(top, text= "Enter Race File Directory Path")
    my_label.pack()
    top.iconbitmap("c:/guis/racehorse.ico")
    entry_1 = Entry(top, font = ("sans_serif", 12))
    entry_1.pack()
    save_button= Button(top, text="Save Path", width = 15, command=save_path)
    save_button.place(x=85, y=100)
     
    top.mainloop()
 
 
         
     
 
def change_path():
    pass
 
 
 
def set_calc_value():
    global calc_value
    global factornames
    global factor_value
    global Factor_ypos
    global calc_valu_pos
    global factor_list
    calc_valu_pos += 25
    calc_value = Calculator_horizontal.get()
    calc_value_label=Label(factor_build,text = calc_value, fg="black",font = ("sans_serif" , 14) ).place(x=1000,y=calc_valu_pos)
    factor_value = calc_value
     
     
# SET  UP CALCULATOR SLIDER TO SET FACTOR WEIGHTS
def get_Caclulator():
    calculator= Toplevel()
    global Calculator_horizontal
    global factornames
    global calc_value
     
    width_of_window = 300
    height_of_window = 300
    screen_width= calculator.winfo_screenwidth()
    screen_height = calculator.winfo_screenheight()
    x_coordinate = (screen_width/2) - (width_of_window/2)
    y_coordinate = (screen_height/2) - (height_of_window/2)
    calculator.geometry("%dx%d+%d+%d" % (width_of_window,height_of_window,x_coordinate,y_coordinate ))
    calculator.iconbitmap("c:/guis/racehorse.ico")
     
    Calculator_horizontal = Scale(calculator, from_= -50, to = 250, length = 200, resolution = 2,orient=HORIZONTAL)
    Calculator_horizontal.place(x=50, y=60)
     
    my_label= Label(calculator, text ="Set Factor Weight", fg= "#104CD6", font = ("sans_serif" , 16)).place(x=50, y=20)
 
    calc_button = Button(calculator, text = "Save Weight",bg="#E2F07F", width = 15,  command = set_calc_value)
    calc_button.place(x=90, y=125)
     
 
 
# SETUP BUTTON STRUCTURE FUNCTION  FOR FACTOR FACTORY
 
     
 
def set_drfvalue():
     
    get_Caclulator()
    global Factor_ypos
    global calc_value
    global factor
    global factor_value
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="drf", fg= "black", font = ("sans_serif" , 16)).place(x=750, y= Factor_ypos)
     
    print(factor_value)
    print(analyst_list)
     
         
         
 
def set_bestspeed():
 
    get_Caclulator()
    global Factor_ypos
    global calc_value
    global factor_list
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Best Speed", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
    factor_list['Best Speed']= calc_value
    print(factor_list[0])
    print(calc_value)
 
 
 
def set_bestspeed_turf():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Best Speed", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_bestspeed_Fast():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Best Speed Fast", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_bestspeed_Off():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Best Speed Off", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_bestspeed_Dist():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Best Speed Dist", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_bestspeed_last3():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Best Speed L 3", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_avgspeed_Last3():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Avg Speed L 3", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_avgspeed_Bst2L3():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Avg Speed B2 L3", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_bestCarroll_speed():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Best Carroll Speed", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_bestCarroll_speed_last():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Best Carroll Speed L3", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_avgCarroll_speed_last():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Avg Carroll Speed L3", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_bstKlein_speed():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Best Klein Speed", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_bstKlein_speed_Last():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Best Klein Speed L3", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_avgKlein_speed_Last():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Avg Klein Speed L3", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_spd_3_back():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Best Speed 3 Back", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_spd_2_back():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Best Speed 2 Back", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_last_speed():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Last Speed", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_quirin__speed_pts():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Quirin Speed Pts", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_bst__cramer_speed():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Best Cramer Speed", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_bst__life_speed():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Best Lifetime Speed", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_early_pace():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Early Pace", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_late_pace():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Late Paced", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_Cpmpetitive_Snap():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Cpmpetitive Snapshot", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_last_E1pace():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Last E1 Pace", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_last_E2pace():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Last E2 Pace", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_avg_last_3E1_pace():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Avg L3 E1 Pace", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_avg_last3_E2pace():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Avg L3 E2 Pace", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_sprint_position_strength():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Sprint Pos Strength", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def  set_route_position_strength():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Route Pos Strength", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_Woods_Form():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Woods Form", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_Win_Percent():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Win Percent", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_in_the_money():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="In The Money", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_days_since_raced():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Days Since Raced", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_last_finish():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Last Finish", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_avg_stretch_pos():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Avg Stretch Pos", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_avg_stretch_pos_L():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="MILFORD", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_Morning_Line():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Morning Line", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_Avg_Earn_Dist():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Avg Earn Dist", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_Avg_Earn_T_Track():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Avg Earn Track", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_avg_earn_turf():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Avg Earn Turf", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_avg_Earn_off():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Avg Earn Off", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_avg_lifetime_earn():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Avg Lifetime Earn ", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_trainer_Win_meet():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Trainer Win % Meet", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_jockey_Win():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Jockey Win % Meet", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_trainer_Win_yr():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Trainer Win % Yr", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_jockey_Win_yr():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Jockey Win % Yr", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_Fast_Class():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Fast Class", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_Last_Purse():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Last Purse", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_avg_purse_L3():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Avg Purse L3", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_Handi_Class():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Handi Class", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_handi_age_earn():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Handi Age Earn", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def  set_dirt_pedigree():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Dirt Pedigree", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_mud_pedigree():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Mud Pedigree", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_turf_pedigree():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Turf Pedigree", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_dist_pedigree():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Dist Pedigree", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_prime_power():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Prime Power", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_mitchell_power():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Mitchell Power", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_mitchell_pwr_speed():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Mitchell Power/Sped", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_mitchell_c_c():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Mitchell C-C", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
def set_bestspd_2_L4():
    get_Caclulator()
    global Factor_ypos
    Factor_ypos += 25
    a_factorname= Label( factor_build, text ="Best Speed 2 L4", fg= "black", font = ("sans_serif" , 16)).place(x=750, y=Factor_ypos)
 
# GET ANALYST'S NAME WITH FACTOR SET
def save_analyst_name():
    global analyst_name
    global analyst_list
    global factor_list
     
    factor_label = Label(factor_build, text = 'Analyst Name', fg= 'black',font = ("sans_serif" , 14) ).place(x=800,y=120)
    analyst_name = entry_analyst_name.get()
    factor_label = Label(factor_build, text = 'Analyst Name', fg= 'black',font = ("sans_serif" , 14) ).place(x=800,y=120)
    factor_namee_label=Label(factor_build,text = analyst_name, fg="#4167E8",font = ("sans_serif" , 14) ).place(x=800,y=145)
    analyst_list[0]= analyst_name
     
 
 
def save_analyst():
    pass
     
# CREATE WINDOW TO FACILITATE USER CHOOSING FACTOR SETS.
def build_factors():
    global factor_build
    global entry_analyst_name
    global labelfactor
    global calc_value
    global factor_namee_label
    global factorname
    global factor
    global factor_location
    global calc_valu_pos
    global Factor_ypos
    global analyst_list
    global factor_list
     
 
    calc_valu_pos = 150
    Factor_ypos = 150
    calc_value = 0
    factor_build = Toplevel()
    analyst_list = [200]
    factor_list =  [100]
    factor_value = 0
 
    Labe20 = Label(factor_build, text="Factor Factory",fg="#1F51B7",font = ("sans_serif" , 16) ).pack()
    Labe21 = Label(factor_build, text="Choose Wisely Grasshopper",fg="#F31839",font = ("sans_serif" , 12) ).pack()
    labelfactor =Label(factor_build)
    entry_factors = StringVar()
    factornames = StringVar()
    factor = StringVar()
    width_of_window = 1100
    height_of_window = 700
    screen_width= factor_build.winfo_screenwidth()
    screen_height = factor_build.winfo_screenheight()
    x_coordinate = (screen_width/2) - (width_of_window/2)
    y_coordinate = (screen_height/2) - (height_of_window/2)
    factor_build.geometry("%dx%d+%d+%d" % (width_of_window,height_of_window,x_coordinate,y_coordinate ))
    factorset_label= Label( factor_build, text ="Name Your Analyst First", fg= "#F33038", font = ("sans_serif" , 12)).place(x=803, y=20)
    entry_analyst_name = Entry(factor_build, font = ("sans_serif", 12))
    entry_analyst_name.place(x=800, y=50)
    save_factorbutton= Button(factor_build, text="Save Analyst's Name", width = 15, command=save_analyst_name)
    save_factorbutton.place(x=830, y=80)
    save_analystbutton= Button(factor_build, text="Save Analyst", fg= '#F52208'  , font = ("sans_serif" , 14) ,width = 15,  command=save_analyst)
    save_analystbutton.place(x=830, y=600)
     
    #factor_label=Label(factor_build,text = factor, fg="#1F51B7",font = ("sans_serif" , 16) ).place(x=800,y=120)
    factor_build.iconbitmap("c:/guis/racehorse.ico")
    my_button20 = Button(factor_build, text = "DRF Speed",bg="#0DDA7D", width = 15,  command = set_drfvalue)
    my_button20.place(x=10, y=25)
    my_button21 = Button(factor_build, text = "Bst Spd T-T", bg='#0DDAD7' ,width = 15, command = set_bestspeed)
    my_button21.place(x=10, y=53)
    my_button22 = Button(factor_build, text = "Bst Spd Turf", bg="#0DDA7D",width = 15, command = set_bestspeed_turf)
    my_button22.place(x=10, y=81)
    my_button23 = Button(factor_build, text = "Bst Spd F-T", bg='#0DDAD7',width = 15, command = set_bestspeed_Fast)
    my_button23.place(x=10, y=109)
    my_button24 = Button(factor_build, text = "Bst Spd Off", bg="#0DDA7D",width = 15, command = set_bestspeed_Off)
    my_button24.place(x=10, y=137)
    my_button25 = Button(factor_build, text = "Bst Spd Dist", bg='#0DDAD7',width = 15, command = set_bestspeed_Dist)
    my_button25.place(x=10, y=165)
    my_button26 = Button(factor_build, text = "Bst Spd Last 3", bg="#0DDA7D",width = 15, command = set_bestspeed_last3)
    my_button26.place(x=10, y=193)
    my_button27 = Button(factor_build, text = "Average Speed L3", bg='#0DDAD7',width = 15, command = set_avgspeed_Last3)
    my_button27.place(x=10, y=221)
    my_button28 = Button(factor_build, text = "Avg Speed B2 L3", bg="#0DDA7D",width = 15, command = set_avgspeed_Bst2L3)
    my_button28.place(x=10, y=249)
    my_button29 = Button(factor_build, text = "Bst Carroll Spd", bg='#0DDAD7',width = 15, command = set_bestCarroll_speed)
    my_button29.place(x=10, y=277)
    my_button30 = Button(factor_build, text = "Bst Carroll Spd L", bg="#0DDA7D",width = 15, command = set_bestCarroll_speed_last)
    my_button30.place(x=10, y=305)
    my_button31 = Button(factor_build, text = "Avg Carroll Spd L", bg='#0DDAD7',width = 15, command = set_avgCarroll_speed_last)
    my_button31.place(x=10, y=333)
    my_button32 = Button(factor_build, text = "Bst Klein Spd", bg="#0DDA7D",width = 15, command = set_bstKlein_speed)
    my_button32.place(x=10, y=361)
    my_button33 = Button(factor_build, text = "Bst Klein Spd L", bg='#0DDAD7',width = 15, command = set_bstKlein_speed_Last)
    my_button33.place(x=10, y=389)
    my_button34 = Button(factor_build, text = "Avg Klein Spd L", bg="#0DDA7D",width = 15, command = set_avgKlein_speed_Last)
    my_button34.place(x=10, y=417)
    my_button35 = Button(factor_build, text = "Spd 3 Back", bg='#0DDAD7',width = 15, command = set_spd_3_back)
    my_button35.place(x=10, y=445)
    my_button36 = Button(factor_build, text = "Spd 2 Back", bg="#0DDA7D",width = 15, command = set_spd_2_back)
    my_button36.place(x=10, y=473)
    my_button37 = Button(factor_build, text = "Last Speed", bg='#0DDAD7',width = 15, command = set_last_speed)
    my_button37.place(x=10, y=501)
    my_button38 = Button(factor_build, text = "Quirin Speed Pts", bg="#0DDA7D",width = 15, command = set_quirin__speed_pts)
    my_button38.place(x=10, y=529)
    my_button39 = Button(factor_build, text = "Bst Cramer Speed",bg='#0DDAD7', width = 15, command = set_bst__cramer_speed)
    my_button39.place(x=10, y=557)
    my_button40 = Button(factor_build, text = "Bst Lifdetime Speed", bg="#0DDA7D",width = 15, command = set_bst__life_speed)
    my_button40.place(x=10, y=585)
    my_button41 = Button(factor_build, text = "Bst Spd2 L4 ", bg='#0DDAD7',width = 15, command = set_bestspd_2_L4)
    my_button41.place(x=10, y=613)
    my_button80= Button(factor_build, text = "Early Pace", bg='#0DDAD7',width = 15, command = set_early_pace)
    my_button80.place(x=10, y=641)
    my_button42 = Button(factor_build, text = "Late Pace", bg="#0DDA7D",width = 15, command = set_late_pace)
    my_button42.place(x=160, y=25)
    my_button43 = Button(factor_build, text = "Cpmpetitive Snap", bg='#0DDAD7',width = 15, command = set_Cpmpetitive_Snap)
    my_button43.place(x=160, y=53)
    my_button44 = Button(factor_build, text = "Last E1 Pace", bg="#0DDA7D",width = 15, command = set_last_E1pace)
    my_button44.place(x=160, y=81)
    my_button45 = Button(factor_build, text = "Last E2 Pace", bg='#0DDAD7',width = 15, command = set_last_E2pace)
    my_button45.place(x=160, y=109)
    my_button46 = Button(factor_build, text = "Avg Last 3-E1 Pace", bg="#0DDA7D",width = 15, command = set_avg_last_3E1_pace)
    my_button46.place(x=160, y=137)
    my_button47 = Button(factor_build, text = "Avg Last 3-E2 Pace", bg='#0DDAD7',width = 15, command = set_avg_last3_E2pace)
    my_button47.place(x=160, y=165)
    my_button48 = Button(factor_build, text = "Sprint Position Str", bg="#0DDA7D",width = 15, command = set_sprint_position_strength)
    my_button48.place(x=160, y=193)
    my_button49 = Button(factor_build, text = "Route Position Str", bg='#0DDAD7',width = 15, command = set_route_position_strength)
    my_button49.place(x=160, y=221)
    my_button50 = Button(factor_build, text = "Woods Form", bg="#0DDA7D",width = 15, command = set_Woods_Form)
    my_button50.place(x=160, y=249)
    my_button51 = Button(factor_build, text = "Win Percent", bg='#0DDAD7',width = 15, command = set_Win_Percent)
    my_button51.place(x=160, y=277)
    my_button52 = Button(factor_build, text = "In The Money", bg="#0DDA7D",width = 15, command = set_in_the_money)
    my_button52.place(x=160, y=305)
    my_button53 = Button(factor_build, text = "Days Since Raced", bg='#0DDAD7',width = 15, command = set_days_since_raced)
    my_button53.place(x=160, y=333)
    my_button54 = Button(factor_build, text = "Last Finish", bg="#0DDA7D",width = 15, command = set_last_finish)
    my_button54.place(x=160, y=361)
    my_button55 = Button(factor_build, text = "Avg Stretch Pos", bg='#0DDAD7',width = 15, command = set_avg_stretch_pos)
    my_button55.place(x=160, y=389)
    my_button56 = Button(factor_build, text = "Avg Stretch Pos L", bg="#0DDA7D",width = 15, command = set_avg_stretch_pos_L)
    my_button56.place(x=160, y=417)
    my_button57 = Button(factor_build, text = "Morning Line", bg='#0DDAD7',width = 15, command = set_Morning_Line)
    my_button57.place(x=160, y=445)
    my_button58 = Button(factor_build, text = "Avg Earn Dist", bg="#0DDA7D",width = 15, command = set_Avg_Earn_Dist)
    my_button58.place(x=160, y=473)
    my_button59= Button(factor_build, text = "Avg Earn T-Track", bg='#0DDAD7',width = 15, command = set_Avg_Earn_T_Track)
    my_button59.place(x=160, y=501)
    my_button60 = Button(factor_build, text = "Avg Earn Turf", bg="#0DDA7D",width = 15, command = set_avg_earn_turf)
    my_button60.place(x=160, y=529)
    my_button61= Button(factor_build, text = "Avg Earn Off", bg='#0DDAD7',width = 15, command = set_avg_Earn_off)
    my_button61.place(x=160, y=557)
    my_button62 = Button(factor_build, text = "Avg Lifetime Earn", bg="#0DDA7D",width = 15, command = set_avg_lifetime_earn)
    my_button62.place(x=160, y=585)
    my_button63= Button(factor_build, text = "Trainer % Cur Meet", bg='#0DDAD7',width = 15, command = set_trainer_Win_meet)
    my_button63.place(x=160, y=613)
    my_button64 = Button(factor_build, text = "Jockey % Cur Meet", bg="#0DDA7D",width = 15, command = set_jockey_Win)
    my_button64.place(x=310, y=81)
    my_button65= Button(factor_build, text = "Trainer % Cur Yr", bg='#0DDAD7',width = 15, command = set_trainer_Win_yr)
    my_button65.place(x=310, y=109)
    my_button66 = Button(factor_build, text = "Jockey % Cur Yr", bg="#0DDA7D",width = 15, command = set_jockey_Win_yr)
    my_button66.place(x=310, y=137)
    my_button67= Button(factor_build, text = "Fast Class", bg='#0DDAD7',width = 15, command = set_Fast_Class)
    my_button67.place(x=310, y=165)
    my_button68 = Button(factor_build, text = "Last Purse", bg="#0DDA7D",width = 15, command = set_Last_Purse)
    my_button68.place(x=310, y=193)
    my_button69= Button(factor_build, text = "Avg Purse L3", bg='#0DDAD7',width = 15, command = set_avg_purse_L3)
    my_button69.place(x=310, y=221)
    my_button70 = Button(factor_build, text = "Handi Class", bg="#0DDA7D",width = 15, command = set_Handi_Class)
    my_button70.place(x=310, y=249)
    my_button71= Button(factor_build, text = "Handi Age Earn", bg='#0DDAD7',width = 15, command = set_handi_age_earn)
    my_button71.place(x=310, y=277)
    my_button72 = Button(factor_build, text = "Dirt Pedigree", bg="#0DDA7D",width = 15, command = set_dirt_pedigree)
    my_button72.place(x=310, y=305)
    my_button73= Button(factor_build, text = "Mud Pedigree", bg='#0DDAD7',width = 15, command = set_mud_pedigree)
    my_button73.place(x=310, y=333)
    my_button74 = Button(factor_build, text = "Turf Pedigree", bg="#0DDA7D",width = 15, command = set_turf_pedigree)
    my_button74.place(x=310, y=361)
    my_button75= Button(factor_build, text = "Dist Pedigree", bg='#0DDAD7',width = 15, command = set_dist_pedigree)
    my_button75.place(x=310, y=389)
    my_button76 = Button(factor_build, text = "Prime Power", bg="#0DDA7D",width = 15, command = set_prime_power)
    my_button76.place(x=310, y=417)
    my_button77= Button(factor_build, text = "Mitchell Power", bg='#0DDAD7',width = 15, command = set_mitchell_power)
    my_button77.place(x=310, y=445)
    my_button78 = Button(factor_build, text = "Mitchell Pwr/Speed", bg="#0DDA7D",width = 15, command = set_mitchell_pwr_speed)
    my_button78.place(x=310, y=473)
    my_button79= Button(factor_build, text = "Mitchell C-C", bg='#0DDAD7',width = 15, command = set_mitchell_c_c)
    my_button79.place(x=310, y=501)
 
     
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
def build_analyst():
    pass
 
def delete_analyst():
    pass
def close_handifast():
    pass
 
 
 
    # DEFINE MENU
my_menu = Menu(root)
root.config(menu=my_menu)
 
 
#CREATE MENU ITEMS
file_menu = Menu(my_menu)
my_menu.add_cascade(label="Configure Program", menu=file_menu)
file_menu.add_command(label="Initialize Setup Files", command=setup_command)
file_menu.add_separator()
file_menu.add_command(label="Change File directory Path", command=change_path)
file_menu.add_separator()
file_menu.add_command(label="Build Race Analyst", command=build_factors)
#file_menu.add_command(label="Build Race Analyst", command=build_analyst)
file_menu.add_command(label="Delete Race Analyst", command=delete_analyst)
file_menu.add_separator()
file_menu.add_command(label="Close Handifast", command=close_handifast)
 
 
     
 
 
 
#CREATE LABELS
my_label1= Label( text ="Race Tracks", fg= "black", font = ("sans_serif" , 16)).place(x=150, y=25)
my_label2= Label( text ="Aceptable Data Types:", fg= "black", font = ("sans_serif" , 16)). place(x=700, y=25)
my_label3= Label(text= "***jcp",  fg= "red", font = ("sans_serif" , 16)).place(x =700, y=50)
my_label4= Label(text= "***drf",  fg= "blue", font = ("sans_serif" , 16)).place(x =775, y=50)
my_label5= Label(text= "***mcp",  fg= "brown", font = ("sans_serif" , 16)).place(x =850, y=50)
my_label6= Label(text= "Enter Date",  fg= "black", font = ("sans_serif" , 16)).place(x =450, y=25)
 
 
 
# CREATE DATE ENTRY  FUNCTION
def  enter_racedate():
    global Race_date
    Race_date = StringVar()
    Race_date = e.get()
     
 
#CREATE DATE INPUT WIDGET
e = Entry(root, font= ("sans_serif", 12))
e.place(x=415, y=65)
 
 
#CREATE ENTER RACEDATE BUTTON
my_button = Button(root, text = "Enter", width = 15, command=enter_racedate)
my_button.place(x=443, y=100)
 
 
 
def initialize_dict():
    track_name = line[0]
    race_num =  line[2]
    surface =  line[6]
 
 
    # LOAD HORSE INFO INTO ARRAY
 
     
     
     
 
# DEFINE LOAD RACE FILE FUNCTION
def load_racefiles() :
    count = 0
    master_race_file = []
    rows = 100
    columns = 100
    horse_array = [0 for i in range(rows)]
    file_name = StringVar()
    f_name = StringVar()
    #file_dir = (r"C:\2020")
    fd =    open("dirpath", "r")
    file_dir = (fd.read())
    fd.close()
    os.chdir(file_dir)
    for f in os.listdir(file_dir):
        file_name, file_ext = os.path.splitext(f)
        f_name = file_name + file_ext
        file_name = file_name.strip()[3:]
        line_counter = 0
        if file_name == Race_date and file_ext == ".jcp":
            with open(f_name, "r") as csv_file:
                csv_reader = csv.reader(csv_file)
                 
                for line in csv_reader:
                     
                     
                     
 
                    track_name = line[0]
                    race_num =  line[2]
                    surface =  line[6]
                    race_type =  line[8]
                    purse = line[11]
                    trn_starts_curmeet = line[28]
                    trn_wins_curmeet = line[29]
                    jock_sts_curmeet =  line[34]
                    jock_wins_curmeet =  line[35]
                    trn_starts_curyear = line[1146]
                    trn_wins_curyear = line[1147]
                    jock_sts_curyear =  line[1156]
                    jock_wins_curyear =  line[1157]
                    trn_starts_prevyear = line[1151]
                    trn_wins_prevyear = line[1152]
                    jock_sts_prevyear =  line[1161]
                    jock_wins_prevyear =  line[1162]
                    morn_line = line[43]
                    horse_name  = line[44]
                    year_of_birth = line[45]
                    hstarts_todays_dist = line[64]
                    hwins_todays_dist = line[65]
                    hstarts_todays_track = line[69]
                    hwins_todays_track = line[70]
                    hstarts_turf = line[74]
                    hwins_turf = line[75]
                    hstarts_mud = line[79]
                    hwins_mud = line[80]
                    hstarts_cur_yr = line[84]
                    hwins_cur_yr = line[85]
                    hstarts_prev_yr = line[90]
                    hwins_prev_yr = line[91]
                    hstarts_life = line[96]
                    hwins_life = line[97]
                    days_since = line[223]
                    power_rating = line[250]
                    dist_yards1 = line[315]
                    dist_yards2 = line[316]
                    dist_yards3 = line[317]
                    dist_yards4 = line[318]
                    dist_yards5 = line[319]
                    dist_yards6 = line[320]
                    dist_yards7 = line[321]
                    dist_yards8 = line[322]
                    dist_yards9 = line[323]
                    dist_yards10 = line[324]
                    surface1 = line[325]
                    surface2 = line[326]
                    surface3 = line[327]
                    surface4 = line[328]
                    surface5 = line[329]
                    surface6 = line[330]
                    surface7 = line[331]
                    surface8 = line[332]
                    surface9 = line[333]
                    surface10 = line[334]
                    entrants1 =  line[345]
                    entrants2 =  line[346]
                    entrants3 =  line[347]
                    entrants4 =  line[348]
                    entrants5 =  line[349]
                    entrants6 =  line[350]
                    entrants7 =  line[351]
                    entrants8 =  line[352]
                    entrants9 =  line[353]
                    entrants10 =  line[354]
                    first_call1 = line[575]
                    first_call2 = line[576]
                    first_call3 = line[577]
                    first_call4 = line[578]
                    first_call5 = line[579]
                    first_call6 = line[580]
                    first_call7 = line[581]
                    first_call8 = line[582]
                    first_call9 = line[583]
                    first_call10 = line[584]
                    second_call1 = line[585]
                    second_call2 = line[586]
                    second_call3 = line[587]
                    second_call4 = line[588]
                    second_call5 = line[589]
                    second_call6 = line[590]
                    second_call7 = line[591]
                    second_call8 = line[592]
                    second_call9 = line[593]
                    second_call0 = line[594]
                    finish_Position = line[615]
                    last_peed = line[845]
                    speed_2back = line[846]
                    speed_3back = line[847]
                    bestSpeed_Life  = line[1327]
                    bestSpeed_Fasttrack = line[1177]
                    bestSpeed_turf = line[1178]
                    bestSpeed_offtrack = line[1179]
                    bestSpeed_dist = line[1180]
                    race_conditions = line[15]
                    todays_race_classification = line[10]
                     
                     
 
                     
                    h = {'track' : track_name,
                    'race_number' : race_num,
                    'todays_surface' : surface,
                    'race_type' : race_type,
                    'todays_purse' : purse,
                    'trn_starts_curmeet' : trn_starts_curmeet,
                    'trn_wins_curmeet' : trn_wins_curmeet,
                    'jock_sts_curmeet' : jock_sts_curmeet,
                    'jock_wins_curmeet' : jock_wins_curmeet,
                    'trn_starts_prevyear' : trn_starts_prevyear,
                    'trn_wins_prevyear' : trn_wins_prevyear,
                    'jock_sts_prevyear' : jock_sts_prevyear,
                    'jock_wins_prevyear' : jock_wins_prevyear,
                    'morn_line' : morn_line,
                    'horse_name' : horse_name,
                    'year_of_birth' : year_of_birth,
                    'hstarts_todays_dist' : hstarts_todays_dist,
                    'hwins_todays_dist ' : hwins_todays_dist,
                    'hstarts_todays_track' : hstarts_todays_track,
                    'hwins_todays_track' :hwins_todays_track,
                    'hstarts_turf' : hstarts_turf,
                    'hwins_turf' : hwins_turf,
                    'hstarts_mud' : hstarts_mud,
                    'hwins_mud' : hwins_mud,
                    'hstarts_cur_yr' : hstarts_cur_yr,
                    'hwins_cur_yr' : hwins_cur_yr,
                    'hstarts_prev_yr' : hstarts_cur_yr,
                    'hwins_prev_yr' : hwins_cur_yr,
                    'hstarts_life' : hstarts_life,
                    'hwins_life' : hwins_life,
                    'days_since' : days_since,
                    'power_rating' : power_rating,
                    'dist_yards1' : dist_yards1,
                    'dist_yards2' : dist_yards2,
                    'dist_yards3' : dist_yards3,
                    'dist_yards4' : dist_yards4,
                    'dist_yards5' : dist_yards5,
                    'dist_yards6' : dist_yards6,
                    'dist_yards7' : dist_yards7,
                    'dist_yards8' : dist_yards8,
                    'dist_yards9' : dist_yards9,
                    'dist_yards10' : dist_yards10,
                    'surface1' : surface1,
                    'surface2' : surface2,
                    'surface3' : surface3,
                    'surface4' : surface4,
                    'surface5' : surface5,
                    'surface6' : surface6,
                    'surface7' : surface7,
                    'surface8' : surface8,
                    'surface9' : surface8,
                    'surface10' : surface10,
                    'entrants1' : entrants1,
                    'entrants2' : entrants2,
                    'entrants3' : entrants3,
                    'entrants4' : entrants4,
                    'entrants5' : entrants5,
                    'entrants6' : entrants6,
                    'entrants7' : entrants7,
                    'entrants8' : entrants8,
                    'entrants9' : entrants9,
                    'entrants10' : entrants10,
                    'first_call1' : first_call1,
                    'first_call2' : first_call2,
                    'first_call3' : first_call3,
                    'first_call4' : first_call4,
                    'first_call5' : first_call5,
                    'first_call6' : first_call6,
                    'first_call7' : first_call7,
                    'first_call8' : first_call8,
                    'first_call9' : first_call9,
                    'first_call10' : first_call10,
                    'second_call1' : second_call1,
                    'second_call2' : second_call2,
                    'second_call3' : second_call3,
                    'second_call4' : second_call4,
                    'second_call5' : second_call5,
                    'second_call6' : second_call6,
                    'second_call7' : second_call7,
                    'second_call8' : second_call8,
                    'second_call9' : second_call9,
                    'second_call0' : second_call0,
                    'finish_Position' : finish_Position,
                    'last_peed' : last_peed,
                    'speed_2back' : speed_2back,
                    'speed_3back' : speed_3back,
                    'trn_starts_curyear' : trn_starts_curyear,
                    'trn_wins_curyear' : trn_wins_curyear,
                    'jock_sts_curyear' : jock_sts_curyear,
                    'jock_wins_curyear' : jock_wins_curyear,
                    'bestSpeed_Life' : bestSpeed_Life,
                    'bestSpeed_Fasttrack' : bestSpeed_Fasttrack,
                    'bestSpeed_turf' : bestSpeed_turf,
                    'bestSpeed_offtrack' : bestSpeed_offtrack,
                    'bestSpeed_dist' : bestSpeed_dist,
                    'race_conditions' : race_conditions,
                    'todays_race_classification' : todays_race_classification
 
                     
 
                 
                        }
 
                master_race_file.append(h )
                line_counter +=1
                 
     
                         
                 
 
 
    print(master_race_file)
    print(line_counter)
                                 
                         
    my_labeldone= Label( text ="Downloading Complete", fg= "black", font = ("sans_serif" , 16)).place(x=500, y=500)                
 
 
            #print(todays_race_classification)
     
 
my_button1 = Button(root, text = "Load Race Files", width = 15, command = load_racefiles)
my_button1.place(x=443, y=150)
 
 
 
 
root.mainloop()
Reply
#4
I just needed to move the list indentation one spot to the right.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to write variable in a python file then import it in another python file? tatahuft 4 876 Jan-01-2025, 12:18 AM
Last Post: Skaperen
  JSON File - extract only the data in a nested array for CSV file shwfgd 2 1,037 Aug-26-2024, 10:14 PM
Last Post: shwfgd
  FileNotFoundError: [Errno 2] No such file or directory although the file exists Arnibandyo 0 838 Aug-12-2024, 09:11 AM
Last Post: Arnibandyo
  "[Errno 2] No such file or directory" (.py file) IbrahimBennani 13 6,187 Jun-17-2024, 12:26 AM
Last Post: AdamHensley
  Reading an ASCII text file and parsing data... oradba4u 2 1,393 Jun-08-2024, 12:41 AM
Last Post: oradba4u
  file open "file not found error" shanoger 8 6,183 Dec-14-2023, 08:03 AM
Last Post: shanoger
Sad problems with reading csv file. MassiJames 3 2,500 Nov-16-2023, 03:41 PM
Last Post: snippsat
  trouble reading string/module from excel as a list popular_dog 0 893 Oct-04-2023, 01:07 PM
Last Post: popular_dog
  Need to replace a string with a file (HTML file) tester_V 1 1,868 Aug-30-2023, 03:42 AM
Last Post: Larz60+
  Reading a file name fron a folder on my desktop Fiona 4 2,049 Aug-23-2023, 11:11 AM
Last Post: Axel_Erfurt

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020