Your responses to advice and questions in the comments suggest to me that this code is not really yours and you have no clear idea what this line
sequence_type, sequence_name = video_path.split(".avi")[0].split("/")[-2:]
is supposed to do. So let me explain. It takes video_path
, which is a full path to an .avi
file, for example '~/folder/subfolder/subsubfolder/myfile.avi'
. It splits off the extension .avi
, and from what remains, that is, '~/folder/subfolder/subsubfolder/myfile'
, it takes the last two elements, that is subsubfolder
and myfile
, and uses those as values for sequence_type
and sequence_name
.
But for that to work, video_path
has to contain both subsubfolder
and myfile
, with a slash between, so, at a minimum, 'subsubfolder/myfile.avi'
.
One of the pathnames returned by glob.glob()
does not contain even one /
character. That is why split("/")
is returning a 1-list, which is not enough to unpack into the 2-tuple (sequence_type, sequence_name)
, resulting in the error Not enough values to unpack.
The only reason that occurs to me why this might be happening is that you are working on Windows where the path separator is not /. That would mean that the pathname your code is getting back from glob.glob()
would be something like 'C:Usersfoldersubfoldersubsubfoldermyfile.avi'
. No slashes: there couldn't be, because Windows filenames can't contain slashes.
That is the reason why commenters asked you to show us the value you were trying to unpack, instead of just telling us about it. Programming problems are very often about tiny specific details. So, in the absence of an explicit response from you, this is still only a guess, but if the guess is correct, the line that is giving you the error should be
sequence_type, sequence_name = video_path.split(".avi")[0].split("\")[-2:]
(note, you have to double the backslash) or, if you want to the code to be platform-independent,
sequence_type, sequence_name = video_path.split(".avi")[0].split(os.path.sep)[-2:]