Key error #582
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hi Allen! I'm going to include the code I used in this cell below. I think you need to change the end_index = -4 , and you could also try commenting out (using # in front of the later code section for opening the band and accumulate) and use .print(band_name) or path or id to make sure that's working before opening the band to accumulate. Also I had to (multiple times) restart the kernel and rerun the code, so if fixing the code doesn't help I would do this and even close out of vs code entirely and reopen the app. Hopefully some or all of this helps! (Also the code copies funny into this cell so pay attention to your own indentation pattern.) Define band labelsbands = { band_dict = {}
band_dict |
Beta Was this translation helpful? Give feedback.
-
@allenmoench it looks to me like the problem here is that your dictionary keys are not matching what you are pulling out of the file name. And it looks to me like the reason for that is that you are missing the last character in the band name! Notice that it's looking for 'B0', rather than 'B0x'. In Python, when you index a range, it does not include the end of the range. That means you have to go one past what you might think. In this case, your end_index will need to be -4 in order to include the character at index -5. |
Beta Was this translation helpful? Give feedback.
@allenmoench it looks to me like the problem here is that your dictionary keys are not matching what you are pulling out of the file name. And it looks to me like the reason for that is that you are missing the last character in the band name! Notice that it's looking for 'B0', rather than 'B0x'.
In Python, when you index a range, it does not include the end of the range. That means you have to go one past what you might think. In this case, your end_index will need to be -4 in order to include the character at index -5.