I have a list of filepaths in a master file
/home/tmp/dir1/file1.xml
/home/tmp/dir2/file2.xml
/home/tmp/dir2/file3.xml
I am trying to extract the names like "file1", "file2", "file3", without the .xml
or the leading filepath
So in my code, I am doing something like:
for line in masterfile:
fname = line.rsplit('/', 1) //e.g : [/home/tmp/dir1, file1.xml]
fname_noext = (fname[1]).rsplit('.xml')
print fname_noext[0]
I keep getting
fname_noext = (fname[1]).rsplit('.xml')
IndexError: list index out of range
Any idea what I might be doing wrong? I checked for trailing white space etc, doesn't look like there is anything there.