Python Forum
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Really stumped now
#1
I thought I had fixed my problem. In fact I marked post solved. The following code works as long as user selects Race 1. But select any other race number and it won't print out. Throws the following error.

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
	
	#if fileFound ==True:

		
		 
	
	
	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:19 ].values
		
		

		for i in range(0,len(xx)):
			if int(xx[hcount][1])== int(race_number):
			 
				print(xx[hcount][18])					
				hcount+=1	
Select race 1 and this is the print out:
TICKET TO RICHES
FLASHY PATCH
HAUTE PROSPECT
MISS VICKI
HONEST GINGER
ABOGADA
But if any other race number selected it throws this error:

Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Milford\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 1883, in __call__
return self.func(*args)
File "testloop.py", line 134, in select_track
load_track_to_Handi()
File "testloop.py", line 95, in load_track_to_Handi
if int(xx[hcount][0])== int(race_number):
ValueError: invalid literal for int() with base 10: 'AP '


I don't understand this at all. I thought the [1] in the code stood for column 1.
Reply


Messages In This Thread
Really stumped now - by Milfredo - Sep-16-2020, 07:08 AM
RE: Really stumped now - by bowlofred - Sep-16-2020, 07:16 AM
RE: Really stumped now - by Milfredo - Sep-16-2020, 09:05 AM
RE: Really stumped now - by bowlofred - Sep-16-2020, 09:06 AM
RE: Really stumped now - by Milfredo - Sep-17-2020, 12:33 AM
RE: Really stumped now - by bowlofred - Sep-17-2020, 03:00 AM
RE: Really stumped now - by buran - Sep-17-2020, 04:28 AM
RE: Really stumped now - by Milfredo - Sep-17-2020, 06:18 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Stumped by my own code (ratio & epoch-time calculation). MvGulik 2 2,222 Dec-30-2020, 12:04 AM
Last Post: MvGulik
  Still Stumped Milfredo 2 2,167 Sep-02-2020, 07:48 AM
Last Post: Milfredo
  attribute error stumped on how to fix it. hank4eva 7 5,030 Aug-11-2020, 04:47 AM
Last Post: hank4eva

Forum Jump:

User Panel Messages

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