Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Index Out Of Range problem
#5
(Dec-08-2018, 09:14 PM)buran Wrote:
(Dec-08-2018, 09:02 PM)yelyah Wrote: It even prints after elif condition can_message[4] as value "d"
well, if it raise error on that line, it cannot print after that :-)

EDIT: can you upload sample file that you parse and that cause the error

Yeeep I just got idea what could be the problem and it seems that if message is shorter then 5 elements it will make this error.

Quote:0.001051 1 1 Rx d 8 00 00 00 05 00 00 00 00 Length = 242000 BitCount = 125 ID = 1
0.001301 1 1 Rx d 8 00 00 00 05 00 00 00 00 Length = 242000 BitCount = 125 ID = 1
0.001549 1 6 Rx d 8 03 00 00 00 00 00 00 00 Length = 240000 BitCount = 124 ID = 6
0.001800 1 9 Rx d 8 04 00 00 00 00 00 00 00 Length = 242000 BitCount = 125 ID = 9
0.002050 1 9 Rx d 8 04 00 00 00 00 00 00 00 Length = 242000 BitCount = 125 ID = 9
2.5158 1 OverloadFrame

because my recognizer function is

def message_type_recognizer(can_message):

    if can_message[0] == "date" or can_message[0] == "base" or can_message[0] == "internal" or can_message[0] == "//" or can_message[0] == "Begin" or can_message[1] == "Start":
        header_parser(can_message)

    elif can_message[4] == "d":
        can_message_parser(can_message)

    elif can_message[4] == "r":
        can_remote_frame_parser(can_message)

    elif can_message[2] == "ErrorFrame":
        can_error_frame_parser(can_message)

    elif can_message[2] == "Statistic:":
        can_statistic_event_parser(can_message)

    elif can_message[3] == "Status:chip":
        can_error_event_parser(can_message)

    elif can_message[8] == "TxErr:":
        can_error_event_parser(can_message)

    elif can_message[2] == "OverloadFrame":
        can_overload_frame_parser(can_message)

    else:
        can_end_triggerblock_parser(can_message)
Reply


Messages In This Thread
Index Out Of Range problem - by yelyah - Dec-08-2018, 08:41 PM
RE: Index Out Of Range problem - by buran - Dec-08-2018, 08:52 PM
RE: Index Out Of Range problem - by yelyah - Dec-08-2018, 09:02 PM
RE: Index Out Of Range problem - by buran - Dec-08-2018, 09:14 PM
RE: Index Out Of Range problem - by yelyah - Dec-08-2018, 09:17 PM
RE: Index Out Of Range problem - by buran - Dec-08-2018, 09:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Thumbs Down I hate "List index out of range" Melen 20 3,789 May-14-2023, 06:43 AM
Last Post: deanhystad
Exclamation IndexError: Replacement index 2 out of range for positional args tuple - help? MrKnd94 2 7,131 Oct-14-2022, 09:57 PM
Last Post: MrKnd94
  IndexError: list index out of range dolac 4 2,111 Jul-25-2022, 03:42 PM
Last Post: deanhystad
  I'm getting a String index out of range error debian77 7 2,580 Jun-26-2022, 09:50 AM
Last Post: deanhystad
  IndexError: list index out of range Anldra12 2 1,550 May-03-2022, 01:39 PM
Last Post: Anldra12
  matplotlib x axis range goes over the set range Pedroski55 5 3,431 Nov-21-2021, 08:40 AM
Last Post: paul18fr
  IndexError: list index out of range rf_kartal 6 3,025 Sep-07-2021, 02:36 PM
Last Post: Larz60+
  Python Error List Index Out of Range abhi1vaishnav 3 2,493 Sep-03-2021, 08:40 PM
Last Post: abhi1vaishnav
  IndexError: list index out of range Laplace12 1 2,304 Jun-22-2021, 10:47 AM
Last Post: Yoriz
  IndexError: list index out of range brunolelli 11 6,932 Mar-25-2021, 11:36 PM
Last Post: brunolelli

Forum Jump:

User Panel Messages

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