Python Forum
Appending list Trouble Big Time
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Appending list Trouble Big Time
#5
I struggle with finding the correct logic a lot of the time. So I program with a sledgehammer instead of a scalpel. I am trying to get better. I just changed the extract data to your code.

def extract_horse_data():
	
	horses_name.append( xx[horse_count][18])
	for i in range(105)
        horses_info.append(xx[horse_count][i])

	print(horses_info[18])   # just print here to make sure the horse names were being accessed correctly. Won't be in final program
	horse_single_race_info.append(horses_info)



def load_track_to_Handi():
	my_tracklabel= Label(root, text ="                                                                               ", fg= "#F50808", font = ("sans_serif" , 16)).place(x=380, y=430)
	read_csvfile_into_array()
	
		
	global track_abrev
	global race_number
	global xx
	global horses_name
	global horse_saddle
	global hcount
	global horse_count
	global horse_array
	global horse_single_race_info
	global horses_info
	global horse_data


	horse_array = np.arange(2100).reshape(20,105)
	
	#if fileFound ==True:
	horse_data = {}
	horses_info =  [] 
	horse_single_race_info = []	 
	horse_saddle = []
	horses_name = []
	hcount = 0
	
	
	with open( 'C://guis/f_racefiles/'+ track_abrev + '.csv' , 'r') as race_file:

		
		df = pd.read_csv(race_file, header =None)
		
		xx = df.iloc[ :, 0: 105 ].values
		
		
#READ FILE AND PULL OUT HORSES AND HORSE INFO FOR SELECTED RACE AND TRACK
		for horse_count in range(0,len(xx)):
			
        
			if int(xx[horse_count][1])== int(race_number):
				horses_info.clear()			 
				extract_horse_data()					
				#load_horse_data()
				
				hcount+=1				
				                          				       		
			
			
		 		
		get_scratches()	



#the following is where I start creating factors and where I printed out the 9 data elements checking my work as I go along.

def trnr_jockey(counter):
	trainer_win_curmeet =  (horse_single_race_info[counter][6])	/ (horse_single_race_info[counter][5])
	race_processed.append(trainer_win_curmeet)

	jockey_win_curmeet = round(((horse_single_race_info[counter][8])	/ (horse_single_race_info[counter][7])) * 100, 2)
	race_processed.append(jockey_win_curmeet)
	trainer_Win_Pvyr =  round(((horse_single_race_info[counter][10])	/ (horse_single_race_info[counter][9])) * 100, 2)
	race_processed.append(trainer_Win_Pvyr)
	jockey_Win_Pvyr =  round(((horse_single_race_info[counter][12])	/ (horse_single_race_info[counter][11])) * 100, 2)
	race_processed.append(jockey_Win_Pvyr)
	trainer_Win_Cyr =  round(((horse_single_race_info[counter][14])	/ (horse_single_race_info[counter][13])) * 100, 2)
	race_processed.append(trainer_Win_Cyr )
	jockey_Win_Cyr =  round(((horse_single_race_info[counter][16])	/ (horse_single_race_info[counter][15 ])) * 100, 2)
	race_processed.append(jockey_Win_Cyr)


#	set horses name, morning line,  fold year
def name_mornline_foldyr(counter):
	morning_line = horse_single_race_info[counter][17]
	race_processed.append(morning_line)
	horse_name = horse_single_race_info[counter][18]
	race_processed.append(horse_name)
	fold_yr = horse_single_race_info[counter][19]
	race_processed.append(fold_yr)

	#print(horse_single_race_info)
	
#PROCESS HORSES INFOR TO GET FACTORS
def process_race(scratched_list):
	global race_processed
	global counter

	race_processed = []
	individual_horse_data = {}
	counter = 0

	for i in range(hcount): # need to change this so can cycle through
		
		trnr_jockey(counter)
		name_mornline_foldyr(counter)
		
		counter+=1





	print(race_processed)
at tyhe get_scratches a windo opens, horses are scratched if they need be and then program is sent to the def process_race(scratched_list):
At the bottom of the program I put a print statement in to check the data in xx to make sure the data structure and actual data is correct. It's not part of the program just a way of looking at xx.

print(xx) and check the printout in the ide gitbash.
Reply


Messages In This Thread
Appending list Trouble Big Time - by Milfredo - Sep-28-2020, 05:37 AM
RE: Appending list Trouble Big Time - by bowlofred - Sep-28-2020, 05:53 AM
RE: Appending list Trouble Big Time - by Milfredo - Sep-28-2020, 06:30 AM
RE: Appending list Trouble Big Time - by deanhystad - Sep-28-2020, 08:25 PM
RE: Appending list Trouble Big Time - by Milfredo - Sep-28-2020, 11:02 PM
RE: Appending list Trouble Big Time - by deanhystad - Sep-29-2020, 02:44 AM
RE: Appending list Trouble Big Time - by Milfredo - Sep-29-2020, 07:35 AM
RE: Appending list Trouble Big Time - by Milfredo - Oct-01-2020, 02:59 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  trouble reading string/module from excel as a list popular_dog 0 432 Oct-04-2023, 01:07 PM
Last Post: popular_dog
  Time.sleep: stop appending item to the list if time is early quest 0 1,884 Apr-13-2021, 11:44 AM
Last Post: quest
  Reading and appending list MrSwiss 1 1,736 Mar-01-2021, 09:01 AM
Last Post: Serafim
  concatenating 2 items at a time in a python list K11 3 2,355 Oct-21-2020, 09:34 AM
Last Post: buran
  list trouble rediska 3 2,241 Oct-17-2020, 11:17 AM
Last Post: ibreeden
  Appending to list of list in For loop nico_mnbl 2 2,373 Sep-25-2020, 04:09 PM
Last Post: nico_mnbl
  trouble with list array Milfredo 2 2,048 Sep-16-2020, 12:07 AM
Last Post: Milfredo
  Trouble with converting list , dict to int values! faryad13 7 3,779 Sep-04-2020, 06:25 AM
Last Post: faryad13
  appending list of list glennford49 2 2,161 Mar-29-2020, 09:33 AM
Last Post: ibreeden
  Trouble with list function Eggman72 2 1,746 Mar-23-2020, 09:36 PM
Last Post: Eggman72

Forum Jump:

User Panel Messages

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