0
Q:

python extract thefile name from relative path

import os
print(os.path.basename(your_path))
14
import os
infile = "./../../../../_data/matrix_data/5mer_normalized.tsv"
print(os.path.basename(infile))
>>> "5mer_normalized.tsv"
0
fullpath = '\\path\\to\\file.sql'
filename = str(fullpath).split('.sql')[0].split('\\')[-1:][0]
filename
# returns just 
'file'
-1

New to Communities?

Join the community